variable not being added, help

stibbs stibbs at nothanks.foo
Thu Nov 28 03:36:06 EST 2002


i'm 100% sure the mistake is on my part, but i can't seem to figure out
what the problem is, as you can see by my comment in the code i tried 2
different ways. I am trying to add to pw_attempts and have it stick.


#!/usr/local/bin/python

import sys

username = raw_input("username?\n")

def getpass():
	try: 
		pw_attempts
	except NameError:
		pw_attempts = 0

	password1 = raw_input("password?\n")
	password2 = raw_input("re-enter password.\n")
	#pw_attempts = pw_attempts + 1

	if password1 != password2:
		pw_attempts = pw_attempts + 1

		if pw_attempts > 2: 
			sys.exit()
		print pw_attempts
		print "your password does not match! Try again\n"
		getpass()
	else: 
		pass
getpass()
print "Passwords Matched!"



More information about the Python-list mailing list