我想创建一个程序,我可以记住书中的所有引号或某些字符。一旦选择了测试类型,我想输入一个我能记住的报价,如果它存在于文件中,那么我可以继续输入更多报价。完成后,会显示一个分数。说实话,这就是我已经完成的所有事情 - 我需要对All_AIC提供一些帮助。
def displayMenu():
print('Inspector Calls quotes:')
print('1. All AIC quotes')
print('2. Arthur quotes')
print('3. Sheila quotes')
print('4. Inspector quotes')
print('5. Eric quotes')
print('6. Gerald quotes')
# INPUT menu item
i = input('Please select an option from the menu above(1-6):')
# VALIDATION of menu item
while not (i.isnumeric() and int(i)>=1 and int(i)<=6):
i = input('Error - Please select an option from the menu above(1-3):')
return i # RETURN menu item
while True:
choice = displayMenu()
if choice=='1':
all_AIC()
elif choice=='2':
arthur()
elif choice=='3':
sheila()
elif choice=='4':
inspector()
elif choice=='5':
eric()
elif choice=='6':
gerald()
else:
print('Wrong choice - enter valid number')
def all_AIC(): # Def means defigning a function
print('Write your quotes, press # to finish')
quotes = input('Quotes:') #INPUT username
quotes = quotes.lower()
quotefile = open('all_AIC.txt', 'r')
quotelist = quotefile.readlines()
quotefile.close()
found = False
for line in quotelist:
if str(quotes) in line:
print(line)
found = True
if not found:
print('Quote not found')
quotefile.close()