I have a list:
Student_Grades = ['56', '49', '63']
and I want to convert each of the entries to integers so that I can calculate an average.
Here's my code for converting:
for i in Student_Grades:
Student_Grades = [int(i)]
I keep getting the error
invalid literal for int() with base 10: '56,'
and I don't know what to do.
Here is my full code on how I got Student_Grades Choose_File = str(input("Please enter the exact name of the file to be read in (including file extention) : "))
with open(Choose_File, "r") as datafile:
counter = 1
x = 1
Student_Grades = []
Read = datafile.readlines()
info = Read[counter]
Split_info = info.split()
n = len(Split_info)
while x < n:
Student_Grades.append(Split_info[x])
x = x + 2
The textfile has the format 'MECN1234 56, MECN1357 49, MATH1111 63'