Question: Keep getting type error: Can only concatenate str ( not int ) to str . Heres the code: def toFixed ( value , digits )

Keep getting type error: Can only concatenate str (not "int") to str.
Heres the code:
def toFixed(value, digits):
return "%.*f"%(digits, value)
print("Enter the amount of students:")
amountOfStudents = int(input())
studentsList =[""]*(amountOfStudents)
gradesList =[0]*(amountOfStudents)
total =0
highest =0
saveHighestIndex =0
lowest =100
saveLowestIndex =0
for i in range(0, amountOfStudents -1+1,1):
print("Enter a last name for student" +(i +1)+":")
lastName = input()
studentsList[i]= lastName
print("Enter a grade for student" +(i +1)+":")
grade = int(input())
gradesList[i]= grade
for i in range(0, amountOfStudents -1+1,1):
if gradesList[i]> highest:
highest = gradesList[i]
saveHighestIndex = i
if gradesList[i]< lowest:
lowest = gradesList[i]
saveLowestIndex = i
total = total + gradesList[i]
print("The students and grades entered are:")
for i in range(0, amountOfStudents -1+1,1):
print(studentsList[i]+""+ gradesList[i])
print("Average:"+""+ toFixed(total / amountOfStudents,1))
print("Highest:"+""+ gradesList[saveHighestIndex]+""+ studentsList[saveHighestIndex])
print("Lowest:"+""+ gradesList[saveLowestIndex]+""+ studentsList[saveLowestIndex])
Additionally would like my code to look like:
Enter the amount of students: 5
Enter a last name and grade: Davis 78
Enter a last name and grade: Jones 98
Enter a last name and grade: Larson 100
Enter a last name and grade: Moris 54
Enter a last name and grade:Smith 88
The students and grades entered are
Davis 78
Jones 98
Larson 100
Morris 54
Smith 88
Average: 83.6
Highest: 100 Larson
Lowest: 54 Morris
Rather than it asking me the name, input. Then the grade.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!