file=open('usernames.txt','w+') userList=open("usernames.txt").readlines() Answer="" userName="" print "\nWelcome, please sign in or enter 2 for registration:" userName=raw_input("> ") if (userName in userList or "2"): Answer="Y" if (userName not in userList) or (userName!=2): print"\nI'm sorry, that user is not registered. Please re-enter your user name or enter 2 for registration." userName=raw_input("> ") while(userName not in userList): print"\n I'm sorry, that user name is not registered. Please re-enter your user name or enter 2 for registration." userName=raw_input("> ") if userName == "2": break if userName == "2": print "\nPlease select a user name:" userName=raw_input("> ") while userName in userList: print "\nSorry, that name is already in use. Please select another:" userName=raw_input("> ") print "\nyou entered %s, is this correct? Y/N:"%userName Answer=raw_input("> ") if (Answer=="Y" or Answer=="y"): with open("usernames.txt","a")as myfile: myfile.write("\n%s"%userName) elif False: Answer="N" while (Answer =="N" or Answer=="n"): print"\nPlease re-enter your user name:" userName=raw_input("> ") print"\nYou entered '%s', is this correct? Y/N:"%userName Answer=raw_input("> ") if (Answer=="Y" or Answer=="y"): with open("usernames.txt","a+")as myfile: myfile.write("\n%s"%userName) print "\nHello %s, What would you like to do?"%userName print """\n\t1. View Schedule\n \t2. View Database\n \t3. Add a Parolee\n \t4. Sign out\n""" Menu=raw_input("> ")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question