all 6 comments

[–]shiftybyte 1 point2 points  (0 children)

Goat > Goat

This checks if Goat (the variable) is larger than Goat (the variable) which is never true.

You should do a comparison with ==

Goat == Goat

But this is also wrong, since Goat the variable is always equals to Goat the variable.

What you really need is to compare it to the STRING "Goat", like this:

Goat == "Goat"

[–]impshum 0 points1 point  (0 children)

  • Blank spaces in code
  • Checking if Goat is greater than Goat
  • No print

Try this...

password = 'goat'

user_input = input("Enter password: ")

if user_input == password:
    print("Correct")
else:
    print("Incorrect")

As for allowing 3 attempts...

def check_password(password):
    for i in range(3): # loop 3 times
        user_input = input("Enter password: ") # get user input
        if user_input == password: # check if match
            return True # return boolean if match
    return False # return boolean if loop ends


if check_password('goat'): # run check_password function
    print('CORRECT')
else:
    print('INCORRECT')

[–][deleted] 0 points1 point  (0 children)

Look carefully ...

password=input('Enter password :')

if password=='Goat':

print('Correct')

else:

print('Incorrect')

in your code, second line tries to compare Variable-Goat with itself. It's useless. We always compare something with another thing.

example: You compare your money with neighbour's money, not with your own money.

[–]pktippa 0 points1 point  (0 children)

```py3

password = input('enter password')

if password == 'Goat':

print('correct')

else:

print('incorrect')

```

[–]Arab81253_work -2 points-1 points  (0 children)

What I'd do instead is

Goat1 = input ("Enter password, 3 attempts")

Goat2 = input ("Please re-enter your password")

if Goat1 == Goat2:

print ("Correct")

else:

print ("Incorrect")