Я пытаюсь создать скрипт на Python, который вычисляет окончательную сумму, подлежащую выплате, когда дается список книг.
Я хочу создать меню, в котором пользователь может выбрать несколько вариантов из списка. и примените окончательную скидку. с этими параметрами:
Все книги, изданные после 2000 года, имеют скидку 10%. • Купите книги на общую сумму более 30 фунтов стерлингов, получите скидку 5% от общей суммы.
Доступны следующие книги: • xxxx (1851) £15.20 • xxxx (2010) £13.14 • xxxx (1980) £11.05 • xxxxx (1976) £10.24 • xxxxx (1889) £12.87 • xxxxx (1895) £10.43 • xxxx (1954) £8.12 • xxxx (1886) £7.32 • xxxxx (1843) £4.23 • xxxx (1859) £6.32 • xxx (1861) £13.21
Это моя первая попытка кодирования, пожалуйста, полегче со мной. Заранее спасибо.
Что я уже пробовал:
menu = 3 while menu == 3: print ("Select book option") print ("1 Moby Dick (1851)- £15.20") print ("2 The Terrible Privacy of Maxwell Sim (2010) - £13.14") print ("3 Still Life With Woodpecker (1980) - £11.05") print ("4 Sleeping Murder (1976) - £10.24") print ("5 Three Men in a Boat (1889) - £12.87") print ("6 The Time Machine (1895) - £10.43") print ("7 The Caves of Steel (1954) - £8.12") print ("8 Idle Thoughts of an Idle Fellow (1886) - £7.32") print ("9 A Christmas Carol (1843) - £4.23") print ("10 A Tale of Two Cities (1859) - £6.32") print ("11 Great Expectations (1861) - £13.21") def option(): while True: option = int(input('select an option from 1 to 11 ')) if option > 11 or option < 1: print ("Option not avialable. Try again! ") option() elif option == 1: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter Y to add another option or N to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 2: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter Y to add another option or N to finish: ') def dis10(option, dis): option = 13.14 dis = option * 0.1 dis10 = option - dis if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 3: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 4: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 5: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 6: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 7: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 8: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break if option == 9: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 10: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break elif option == 11: print ("You select option 1 Moby Dick (1851)- £15.20") cont = input('Enter "Y" to add another option or "N" to finish: ') if cont == "N": exit elif cont == "Y": menu = 3 else: break def totaldis(total_amount, totaldis): totaldis = total_amount -