0

I'm trying to learn Python and I tried making just a little "Secret" protected by a password. I also tried to make it so if you typed "help" it would give you a hint. Well I made it so when you type anything that's not the password it would say incorrect and you'd try again. It almost works perfectly except when I type "help" or input the correct password, the "incorrect" still comes up and I have to retype the correct password, which then works. What did I do wrong?

def helpInfo():
    print('The Password is a single Number')

def secret():
    print ('Secret password protected stuff blah blah blah')

def intro():
    print('Hello! What is the Password?')

def check():

    password = 3
    guess = input()

    if guess == password:
        print ('Correct!')

    if guess == help:
        helpInfo()

    if guess != password or help:
        print ('Incorrect! Please try again')
        check()


intro()
check()

Edited by aj9393: Mistakes

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JoshuaBurleson
0

wrong type, watch this magic:

>>> a=input('code: ')
code: 3
>>> a==3
False
>>> a
'3'
>>> print(3)
3
>>> type(a)
<class 'str'>
>>> type(3)
<class 'int'>
>>> a=int(a)
>>> a==3
True

input creates a string, if you want it to be an integer you need to be explicit about it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.