I am looking for an answer to this error with my specific code. I have searched the others and they are still so confusing.
I am unsure why this is happening.
Here is the code section that the error is referencing, followed by the error.
def processScores( file, score):
#opens file using with method, reads each line with a for loop. If content in line
#agrees with parameters in if statements, executes code in if statment. Otherwise, ignores line
with open(file,'r') as f:
for line in f: #starts for loop for all if statements
if line[0].isdigit:
start = int(line)
score.initialScore(start) #checks if first line is a number if it is adds it to intial score
The error message I'm getting:
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
processScores('theText.txt',score)
File "C:/Users/christopher/Desktop/hw2.py", line 49, in processScores
start = int(line)
ValueError: invalid literal for int() with base 10: '\n'
Thanks everyone, I wouldn't be posting this if i didnt find a clear answer in the other posts