Name error: name Susas not defined | Sololearn: Learn to code for FREE!
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)

2nd Mar 2022, 5:04 AM
Sonic_gameryt6 _
11 ответов
+ 5
You need to use quotes(" " or ' ') to denote a string.
2nd Mar 2022, 5:06 AM
Simba
Simba - avatar
+ 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':
2nd Mar 2022, 6:01 AM
A͢J
A͢J - avatar
+ 2
"susas"
2nd Mar 2022, 5:06 AM
Simba
Simba - avatar
+ 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"
2nd Mar 2022, 5:09 AM
Sonic_gameryt6 _
+ 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.
2nd Mar 2022, 1:08 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
+ 1
Simba ok thx
2nd Mar 2022, 5:07 AM
Sonic_gameryt6 _
+ 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':
2nd Mar 2022, 5:07 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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.
2nd Mar 2022, 5:11 AM
NonStop CODING
NonStop CODING - avatar
+ 1
2nd Mar 2022, 5:14 AM
Sonic_gameryt6 _
0
Simba where?
2nd Mar 2022, 5:06 AM
Sonic_gameryt6 _
0
Sonic_gameryt6 _ " susas " this way Password == "susas" you may also use single quotes
2nd Mar 2022, 5:08 AM
NonStop CODING
NonStop CODING - avatar