Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with code
#1
When I create a new account or retry login, It doesn't recognize and im unsure why

logged_in=False
attempts=0
 
enter_name=input('ENTER NAME: ')
enter_password=input('ENTER PASSWORD: ')
 
with open('Data.txt', 'r') as file:
    for line in file:
        name, password = line.split(',')
        if name == enter_name:
            logged_in = password == enter_password
            break
        else:
            attempts+=1
            print('WRONG USERNAME OR PASSWORD')
            enter_option=input('ENTER OPTIONS:\n A-RETRY\n B-NEW ACCOUNT\n')
            while enter_option=='A':
                enter_name=input('ENTER NAME: ')
                enter_password=input('ENTER PASSWORD: ')
                if name == enter_name:
                    logged_in = password == enter_password
                    break
                else:
                    attempts+=1
                    print('WRONG USERNAME OR PASSWORD')
                    enter_option=input('ENTER OPTIONS:\n A-RETRY\n B-NEW ACCOUNT\n')
            while enter_option=='B':
                with open('Data.txt', 'a') as file:
                     enter_new_name=input('ENTER NEW NAME: ')
                     enter_new_password=input('ENTER NEW PASSWORD: ')
                     file.write(enter_new_name+','+enter_new_password+"\n")
                     enter_name=input('ENTER NAME: ')
                     enter_password=input('ENTER PASSWORD: ')
                     if name == enter_name:
                        logged_in = password == enter_password
                        break
                     else:
                        attempts+=1
                        print('WRONG USERNAME OR PASSWORD')
                        enter_option=input('ENTER OPTIONS:\n A-RETRY\n B-NEW ACCOUNT\n')
    

            
if logged_in==True:
    print('Hello',name)
Reply


Messages In This Thread
Need help with code - by SteampunkMaverick12 - Apr-25-2019, 12:47 PM
RE: Need help with code - by buran - Apr-25-2019, 01:12 PM
RE: Need help with code - by SteampunkMaverick12 - Apr-26-2019, 06:36 AM
RE: Need help with code - by perfringo - Apr-26-2019, 07:11 AM

Forum Jump:

User Panel Messages

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