#loop to get input that is not blank, strips input of whitespace def ckin(a): while a=='': a=input().strip() return a #creates list with includes user admin user_names = ['admin'] #Ask for 5 names to store as usernames print('Please enter 5 user names: ') #if username is valid, add to list for i in range(0,5) lib_name=input().strip() lib_name=ckin(lib_name) user_names.append(lib_name) #asks for login name, must be valid print('Enter login name:') log_name=input().strip() log_name=ckin(log_name) #Create a test list that is lower case to compare login #against without altering the cases used by user to creat username list test=[name.lower() for name in user_names] #if login name not in list continue to prompt while log_name.lower() not in test: print('Enter login name:') log_name=input().strip() log_name=ckin(log_name) #find login name in test, then return either response for admin, or login name using #case formatting that original used for original entry for i in range(len(test)): if log_name.lower() == 'admin': print('Hello admin, would you like to see a status report?') break elif log_name.lower() == test[i]: print('Hello '+user_names[i]+', thank you for logging in again') break
Looking for general review self-teaching, Day 4
I haven't learned much but I keep attempting to do what I'm learning with user inputs instead of set entries
My goal here was to be able to create a list that keeps the original entry cases to be used for responding. I created a second list in lower cases to compare to and then responded using the cases the entries were stored as.
Any comments are greatly appreciated!