>>> i,c = "", 0 >>> while i != 'password': ... i=raw_input("Enter your password: ") ... print "You entered %s and you have finished %d tries" % (i,c) ... c+=1 ... if c == 3: break