# Debug the following program and submit the CORRECT version ####### Lists names = ["chris","dan", "edgar", "bonnie", "al", "fran"] usernames = ["202999", "100345", "299999", "309890", "298765", "345678"] passwords = ["password", "password123", "abcdef", "asdfjkl;", "ilovemom", "abc123"] menuChoice = 0 # user's menu choice ###### functions def printList(list):# print listprintprint(list)print def displayMenu():# displays user-friendly, creative menu printprintprint("******* MENU *******")print("1. (D)isplay list 1 in original order")print("2. D(I)splay list 2 in original order")print("3. (F)ind an item in the list 1")print("4. (L)ogin")print("99. (E)xit")printprint def isFound(list, value):# finds a value in list returns True if found, False otherwiseif (value in list):return Trueelse: return False ###### main program while (menuChoice != "99"):displayMenu()menuChoice = input("Enter a menu choice: ")# handling menu choices if (menuChoice == "10" or menuChoice.upper().strip() == "D"):printList(names)elif (menuChoice == "20"):printList(usernames)elif (menuChoice == "30"):value = input("Enter the value you are searching for: ")if (isFound(names, "Cooper")):print(str(value) + " was found")else:print(str(value) + " was not found") elif (menuChoice == "40"):userInputtedUsername = input("Enter username: ")userInputtedPassword = input("Enter password: ") if (isFound(usernames, userInputtedUsername)):positionInList = usernames.index(userInputtedUsername) if (userInputtedPassword == passwords[positionInList]):print("The username does match the password!")# do something here since the user logged in correctlyelse:print("Invalid Password") else:print("That username does not exist.") elif (menuChoice == "99"):print("Goodbye")breakelse:print("You entered an invalid menu choice.")
# Debug the following program and submit the CORRECT version
####### Lists
names = [
"chris",
"dan",
"edgar",
"bonnie",
"al",
"fran"
]
usernames = [
"202999",
"100345",
"299999",
"309890",
"298765",
"345678"
]
passwords = [
"password",
"password123",
"abcdef",
"asdfjkl;",
"ilovemom",
"abc123"
]
menuChoice = 0 # user's menu choice
###### functions
def printList(list):
# print list
print
print(list)
print
def displayMenu():
# displays user-friendly, creative menu
print
print
print("******* MENU *******")
print("1. (D)isplay list 1 in original order")
print("2. D(I)splay list 2 in original order")
print("3. (F)ind an item in the list 1")
print("4. (L)ogin")
print("99. (E)xit")
print
print
def isFound(list, value):
# finds a value in list returns True if found, False otherwise
if (value in list):
return True
else:
return False
###### main program
while (menuChoice != "99"):
displayMenu()
menuChoice = input("Enter a menu choice: ")
# handling menu choices
if (menuChoice == "10" or menuChoice.upper().strip() == "D"):
printList(names)
elif (menuChoice == "20"):
printList(usernames)
elif (menuChoice == "30"):
value = input("Enter the value you are searching for: ")
if (isFound(names, "Cooper")):
print(str(value) + " was found")
else:
print(str(value) + " was not found")
elif (menuChoice == "40"):
userInputtedUsername = input("Enter username: ")
userInputtedPassword = input("Enter password: ")
if (isFound(usernames, userInputtedUsername)):
positionInList = usernames.index(userInputtedUsername)
if (userInputtedPassword == passwords[positionInList]):
print("The username does match the password!")
# do something here since the user logged in correctly
else:
print("Invalid Password")
else:
print("That username does not exist.")
elif (menuChoice == "99"):
print("Goodbye")
break
else:
print("You entered an invalid menu choice.")
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 7 images