0
Name error: name Susas not defined
I'm trying to make a password code (for fun) Here's the code spam = "intruder alert!1!1!1" print("pls give passwordđ") password = input() if password == susas: print(" correct password ") else: print(spam * 100)
12 Answers
+ 5
You need to use quotes(" " or ' ') to denote a string.
+ 8
Sonic_gameryt6 _
You are comparing with string value and anything inside double quotes or single quotes is known as string.
Without quotes it will be treat as a variable so without quotes here susas will be treat as a variable which is undefined.
So there should be:
password == 'susas':
+ 2
"susas"
+ 2
NonStop Coding sorry, Ur late
Also your codenis wrong, there was a space there so it cause the "else" to start instead of "if"
+ 2
If u skip the quotes python wrongly identifies it as a variable and since the variable susan was not defined in your code , Hence a NameError.
+ 1
Simba ok thx
+ 1
Put susas in quotes to make it a string, otherwise, the python compiler sees it as a variable name that doesn't exist instead of a string literal.
if password == 'susas':
+ 1
Sonic_gameryt6 _
I wrote that way so that it look readable
By the way thanks for mentioning that. I'll keep in mind next time.
How to write readable comments properlyđ¤đ¤
and sorry for being late, I forgot to refresh before typing.
+ 1
NonStop Coding it's ok
0
Simba where?
0
Sonic_gameryt6 _
" susas " this way
Password == "susas"
you may also use single quotes