Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

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.formatAbout str.format

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

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

Not necessary
Source Link
Caridorc
  • 27.6k
  • 7
  • 54
  • 135

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

Do not overuse if, instead write:

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

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

About str.format

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

Source Link
Caridorc
  • 27.6k
  • 7
  • 54
  • 135

Do not overuse if, instead write:

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

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

About str.format