Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with my code?
#1
Hey guys so I am writing a basic code which asks you for a password to enter. If you get the password wrong 3 times in a row then you get a time penalty. Everything works except if you get the password wrong I can’t get it to count how many times it has been wrong
password = ('password')
count = 0

def guessing():
    
    guess = raw_input('Please enter the password or type cancel to go exit: ')
    
    if guess == 'cancel':
        print ('Cancelling..')
    else:
        password_guess(guess, password, count)
        
        
        
def password_guess(guess, 
password, count):
    if guess == password:
        print ('Password correct!')
        print('Now opening program')
    else:
        print ('Password incorrect!')
        check_Count(count)


def check_Count(count):
    count = count + 1
    print (count)
    if count == 3:
        print ('You have entered the password wrong 3 times. please wait for 10 seconds')
        for i in range (count):
            print (count - i)
    else:
       guessing()
        
guessing()    
Thanks in advance
Reply


Messages In This Thread
Problem with my code? - by Darbandiman123 - Sep-29-2018, 12:35 PM
RE: Problem with my code? - by gruntfutuk - Sep-29-2018, 01:50 PM
RE: Problem with my code? - by Darbandiman123 - Sep-29-2018, 01:54 PM
RE: Problem with my code? - by gruntfutuk - Sep-29-2018, 01:55 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020