The program is suppose to create and account but if the passwords do not match after the 3rd iteration it's suppose to output that its been too many tries and end the program... I can't seem to figure this out any help would be greatly appreciated.

while 3:
    print ("Welcome to yor account creation")
    name =input('Enter your name: ')
    pasw =input('Enter your password: ')
    paswr =input('Re-enter your password: ')
    if pasw == paswr:
            print ("Your account has been created")
            break;
    if pasw != paswr:
        print ("Please re-enter information")
    if while <=3:
              print ("Too many incorrect tries, your account has not been created")

Recommended Answers

All 4 Replies

You need to set a variable for your while loop and change the bottom if statement. You then need to count to the variable each iteration. Also, you should take the name input and first print statement out of the loop so not to have it repeat each time.

print ("Welcome to yor account creation")
name =input('Enter your name: ')
    
n = 0     #add a variable set to 0
while n != 3:     #include variable in while statement 
	pasw =input('Enter your password: ')
	paswr =input('Re-enter your password: ')
	if pasw == paswr:
		print ("Your account has been created")
		break
	if pasw != paswr:
		print ("Please re-enter information")
		n += 1     #add 1 each iteration
	if n == 3:      #if 3 iterations run print and break
		print ("Too many incorrect tries, your account has not been created")
		break
commented: welcome go contribute! +3

Ahh I see... thank you so much!!!!

No problem. I'm a newbie too. People here are great so don't feel uncomfortable posting. These guys are a wealth of knowledge and willing help!

yea my prof made us switch over to python for this project idk why.. but I definitely won't. thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.