Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I can not get my error to work when I enter a neg number or something over 100 i

ID: 3690238 • Letter: I

Question

I can not get my error to work when I enter a neg number or something over 100 it doesnt work:

Please make the Student List:
Enter First Name: jj
Enter your Last Name: aa
Enter your Average: 34
Enter First Name: jj
Enter your Last Name: hh
Enter your Average: -45
Enter First Name: jj
Enter your Last Name: hh
Enter your Average: 345
Enter First Name:

#################################################################
def Main():
print('Please make the Student List: ')
Input()
#################################################################
def Input():
outfile = open('grades.txt', 'w')
#STUDENT INPUT +++++++++++++++++++++++++
Names = ["" for x in range(11)]
LName = ["" for x in range(11)]
Grade = [0 for x in range(11)]
for i in range(0,len(Names) - 1):
Names[i] = input('Enter First Name: ')
LName[i] = input('Enter your Last Name: ')
Grade[i] = input('Enter your Average: ')
try:
if Grade[i] > 100:
print ("Oops! That was not valid answer.")
Input()
elif Grade[i] <= 0:
print ("Oops! That was not valid answer.")
Input()
except:
print('Something wrong.')
else:
outfile.write(str(Names[i]) + ',' + str(LName[i])+ ': ' + str(Grade[i]) + ' ')
outfile.close()
Open()
  
####################################################################
def Open():
try:
infile = open("grades.txt", "r")
except:

print("Error: can't find file or read data")
line1 = infile.readline()
line2 = infile.readline()
line3 = infile.readline()
line4 = infile.readline()
line5 = infile.readline()
line6 = infile.readline()
line7 = infile.readline()
line8 = infile.readline()
line9 = infile.readline()
line10 = infile.readline()
infile.close()
print()
print(line1)
print(line2)
print(line3)
print(line4)
print(line5)
print(line6)
print(line7)
print(line8)
print(line9)
print(line10)
Main()

Explanation / Answer

change Grade[i] = input('Enter your Average: ') in "def Input():" to

Grade[i] = int(input('Enter your Average: '))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote