0
Problem with "input" statement.
Anytime i try to use the input statement in a program, it always gives me an error output. Example score = input (score) If score <=50 : Print("fair") Print("end") And when i input a value, it always gives me a name error report about 'score'
7 Answers
+ 3
it should be just score=input()
or score=input("score")
also considering you need an integer
it should be score=int(input())
+ 2
It is giving error code: score not defined right??
Try:
score = int(input("Enter the score: "))
This is given in the python lesson
Read it carefully
+ 2
Only writing input will take a string not an integer.... You cannot compare a string with an integer which is 50 in this case
+ 2
Hey Ojih Jude,
The built-in "input" function takes an (optional) string as a parameter that is displayed on the screen so it should always be in quotes if typed directly.
Also it evaluates the user input as a string,
so if we need integer input we convert the input using int() similarly for float input we use float() for conversion and so on.
+ 2
You got NameError here as you have passed in score as a parameter as input(score), which is considered as string by the input function which was still not defined.
+ 1
By the way the syntax is wrong. It is
score=int(input("score"))
if score<=50:
print('fair')
print("end")
0
Ohh, i get now