Why is this code showing the error (ValueError: invalid literal for int() with base 10: 'name') while I run it?

Question:

I don’t know what this is or how this occured. When I ran this same code in ChatGPT, it said that there were no errors, so I felt this was the place to ask.

I tried writing a code in Python for creating a report card. It resulted in this error.

Error : – ValueError: invalid literal for int() with base 10: ‘k’

Code:

#to print marklist with total and percentage

#essential details of the student 
r=int(input('Enter Roll No. :'))
n=int(input('Enter Name:'))
s=int(input('Enter School name :'))

#marks
eng= float(input('Enter your English marks :'))
math= float(input('Enter your Mathematics marks :'))
social=float(input('Enter your Social marks :'))
science=float(input('Enter your Science marks :'))
malayalam= float(input('Enter your Malayalam marks :'))
hindi= float(input('Enter your Hindi marks :'))

#essential calculations
t= eng+math+social+science+malayalam+hindi
p=(t*100)/480

#grade determination
if p>=80:
    grade='A1'
if p>=70:
    grade='A2'
if p>=60:
    grade='B1'
if p>=50:
    grade='B2'
if p>=40:
    grade='C1'
if p>=33:
    grade='C2'
else:
    grade='E'

#representation of earlier input
print ('Roll Number :',r)
print ('Name :',n)
print ('School Name:',s)
print ('Total:',t)
print ('Percentage :',p)
print ('Final Grade:',grade)





        
Asked By: amused_turtle14

||

Answers:

This error because of you had given the datatype as int in the field of ‘name’ and ‘school name’.It should be string. Try:

n = input('Enter Name:')
s = input('Enter school name:')
Answered By: Muhammed Anees K
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.