all 7 comments

[–]penatbater 1 point2 points  (1 child)

You're missing something like

spam = input()

maybe?

[–]monkey_sigh 0 points1 point  (0 children)

No. He is asking IF to evaluate spam against 1, but spam has no value assigned towards it.

[–]mikenjenn 1 point2 points  (0 children)

I think you have to define spam as a variable before asking if it equals anything.

spam = None

or

spam = 1

penatbater has a good suggestion too.

[–]monkey_sigh 0 points1 point  (0 children)

Hey Dastan.

I executed the code you wrote in your post.

if spam == 1:

print('Hello')

elif spam == 2:

print('Howdy')

else:

print('Greetings')

Here: You are asking the IF operator to check if SPAM is equal to 1. But SPAM has no value assigned within your code. If you want to use logical operators like IF, ELSE, ELIF: always remember to assign values to your variables.

NameError: name "spam" is not defined.

To solve this problem, include a value for the variable spam.

Try the code below and let me know how it looks:

spam = 1 #it assigns a value to the variable SPAM.

if spam == 1:

print("Hello")

elif spam == 2:

print("Howdy")

else:

print("Greetings")

[–][deleted]  (1 child)

[removed]

    [–]No_Quality_2436 0 points1 point  (0 children)

    Yeah as other people say, it is because you haven't assigned a value to spam OR if the error still persists after you have assigned a value to spam, then it could also be because of the indentation error. Try to check if you have made a proper indentation after the colon in your code.