You are using the syntax incorrectly here which is why you are getting the error. You need to separate these two 'open' statements using a comma ',' not an 'and'. Like this:
with open('a', 'w') as a and open('b', 'w') as b:
do_something()
If you wish to get an in-depth understanding about python in general you should check out this video: