+ 4

i don't know why my short python scribe show me error massage when i enter 7 as name input.

nam=input() if name==7: print(" ")

1st Apr 2019, 12:03 PM
clovert
clovert - avatar
5 Respostas
+ 4
clovert nam=input() if name==7: #1: nam==7 print(" ") #2: You are trying to compare the string variable "nam" with a number, so nam != 7. You need to convert the string variable "nam" to a number variable, or the number 7 to the character "7".
1st Apr 2019, 12:27 PM
Solo
Solo - avatar
+ 8
clovert You should pay attention to your variable names when you code. Even a slightly different character implies an entirely new variable.
1st Apr 2019, 12:15 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 7
Line 1: The variable is nam Line 2: Some random variable never declared before called name has been used in an expression. To fix, change line 1 "nam" to "name" or "name" to "nam"
1st Apr 2019, 12:11 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
clovert you wrote nam=input() Then your saying if name==7: Your error is in line 1
1st Apr 2019, 12:12 PM
Jella
Jella - avatar
0
Its nam var which have input by user Not name see variable declaration
3rd Apr 2019, 9:08 AM
Tony Stark
Tony Stark - avatar