You can try the below code which creates the new file with "write" acccess.
import sys
def WriteFile():
name = input('Enter name of the file: ')+'.py' # Enter name of the file along with format
try:
file = open(name,'w') # creates a new file or open one with write access
file.close()
except:
print('error') # if code doesn't work, print error
sys.exit(0)
WriteFile()