Skip to main content
3 of 3
replaced http://stackoverflow.com/ with https://stackoverflow.com/

Do not overuse if, instead write:

with open('class{}.txt'.format(class_number), 'a') as myFile:
    myFile.writelines(userscore)
    myFile.close() # Not necessary as Barry noted

The class number 1 will be saved in class1.txt, the number 2 in class2.txt...

About str.format

Caridorc
  • 27.6k
  • 7
  • 54
  • 135