1

I am going back to the basics of python(because I didn't learn it properly when I started) and I found out more about the input function.

So, I tried something very simple, but it doesn't work for some reason.

Here is my code:

loop = input("enter a 5 or a 6: ")

if loop == 5:
    print("In Loop 5")

if loop == 6:
    print("In loop 6")

When I enter a 5 or a 6, it doesn't print anything, and just exits.

Can anyone please tell me what I am doing wrong?

Thanks!!

1 Answers1

2

Because your variable contains a string and you're comparing it to integers. Either compare your variable to strings or convert the input to an integer.