Log in New API Help About

Kod dla zadania książki - 2 rozwiązania (for i if).

1012 bytes of Python
Created 3 months ago — expires in 275 days
https://dpaste.com/BE9JZFJTQ
COPY TO CLIPBOARD SOFT WRAP RAW TEXT DUPLICATE DIFF
vegetarian = input("Czy ktoś spożywa dania wegetariańskie?(tak/nie): ")
vegan = input("Czy ktoś spożywa dania wegańskie?(tak/nie): ")
gluten = input("Czy ktoś spożywa dania bezglutenowe?(tak/nie): ")

joes = ["nie", "nie", "nie", "Joes Gourmet Burgers"]
pizza_Co = ["tak", "nie", "tak", "Main Street Pizza Company"]
caffe = ["tak", "tak", "tak", "Corner Cafe"]
italian = ["tak", "nie", "nie", "Mamas Fine Italian"]
kitchen = ["tak", "tak", "tak", "The Chefs Kitchen"]

'''
for item in joes, pizza_Co, caffe, italian, kitchen:
    if (vegetarian == item[0] and vegan == item[1] and gluten == item[2]):
        print(item[3])
'''
#Rozwiązanie Stricte pod książkę:
if vegetarian == 'tak' and vegan == 'nie' and gluten == 'tak':
      print(pizza_Co[3])
      print(caffe[3])
      print(kitchen[3])
if vegetarian == 'nie' and vegan == 'nie' and gluten == 'nie':
      print(joes[3])
if vegetarian == 'tak' and vegan == 'tak' and gluten == 'tak':
      print(caffe[3])
      print(kitchen[3])

Share: