r/pythonhelp • • Mar 09 '21

SOLVED Need help with an "if" and "input" code

Hello

I am having a problem with this code I am trying to make for my friends, every time I run it it works fine, however when I input "a" it dosent print("Welcome User")

a = (14451444)

a = input("Insert Code: ")

if a == b:

print("Welcome User")

any help with this?

3 Upvotes

2 comments sorted by

4

u/plague-anon Mar 09 '21 edited Mar 09 '21

Hello, mate. You're assigning the variable 'a' twice. There is no 'b' variable.

You must make sure the stored variable and the input variable are the same type.

Make the following changes:

code = str(12345)

user_input = input ("Enter your code: ")

if user_input == code:

#do this if yes

print("yes")

else:

#do this if no

print("no")

2

u/[deleted] Mar 09 '21

Thanks a lot