print ("Welcome To Femboii's Restaraunt")
Name = input ("What's Your Name Sir?\n").capitalize()
EvilGuys = ["Jack", "Ben", "Maria"]
if Name in EvilGuys:
Evil_Status = input ("Are You Evil " Name "?\n").capitalize()
if Evil_Status == "Yes":
Good_Deeds = input ("How Many Good Deeds Have You Done Today " Name "?\n")
Bad_Deeds = input ("How Many Bad Deeds Have You Done Today " Name "?\n")
Good_Deeds = int(Good_Deeds)
Bad_Deeds = int(Bad_Deeds)
elif Evil_Status == "No":
print ("Oh, So You Aren't Evil, Come In You're Welcome!")
else:
print ("Sorry I Didn't Understand You, So Ill Just Take It As A No")
if Good_Deeds >= Bad_Deeds:
print ("Oh, So You Aren't Evil, Come In You're Welcome!")
if Good_Deeds < Bad_Deeds:
print ("GET OUTTTT RIGHT NOWWWWWWWWWW!!!!!!!!!!")
exit ()
print ("Welcome " Name)
FoodMenu = ("Pizza, Crepe, Burger And Shawrma.")
DrinksMenu = ("Black Coffee, Latte, Mocha, Espresso, Crapuccino And Sparkling Water")
FoodMenuList = ["Pizza", "Crepe", "Burger", "Shawrma"]
DrinksMenuList = ["Black Coffee", "Latte", "Mocha", "Espresso", "Crapuccino", "Sparkling Water"]
Order = input ("Here's Our Food Menu\n" FoodMenu "\nAnd Here's Our Drinks Menu\n" DrinksMenu "\nChoose What Serves You The Best.\n").capitalize
while Order not in FoodMenuList or Order not in DrinksMenuList:
if Order in FoodMenuList or Order in DrinksMenuList:
break
if Order not in FoodMenuList or Order not in DrinksMenuList:
input ("Sorry, I Didn't Understand What You Said, Can You Repeat?\n").capitalize()
print (Order)
I Tried To Make It So If He Asked For Something That is not In The menu tells him that the code the ai whatever
could not understand him and if he keeps doing this it will keep saying the
Sorry, I Didn't Understand What You Said, Can You Repeat
and the while loop does not stop
CodePudding user response:
while not (Order in FoodMenuList or Order in DrinksMenuList:
if Order in FoodMenuList or Order in DrinksMenuList:
break
if not (Order in FoodMenuList or Order in DrinksMenuList):
input ("Sorry, I Didn't Understand What You Said, Can You Repeat?\n").capitalize()
print (Order)
Probably has to do with logic. You see:
not P and not Q != not (P and Q)
CodePudding user response:
As others have already pointed out the problem seems to be in the logic of the program.
while Order not in FoodMenuList or Order not in DrinksMenuList:
Here you're checking if the order isn't in the food menu or if the order isn't in the drinks menu.
This will always be True
because the order can't be both in the food menu and in the drinks menu at the same time.
What you want to do is replace or
with and
. That way it will return True
only if the order is in neither of the menus.
Another way of doing it is combining the two menus and checking if the item is in there:
while Order not in FoodMenuList DrinksMenuList:
Also unrelated to the problem but it's not advisable to use
signs to format your strings:
"How Many Bad Deeds Have You Done Today " Name "?\n"
A better way of doing it is to use format strings:
f"How Many Bad Deeds Have You Done Today {Name}?\n"
CodePudding user response:
Uhm, you forgot to push input(...)
into Order
.
Currently it's:
while Order not in FoodMenuList or Order not in DrinksMenuList:
if Order in FoodMenuList or Order in DrinksMenuList:
break
if Order not in FoodMenuList or Order not in DrinksMenuList:
input ("Sorry, I Didn't Understand What You Said, Can You Repeat?\n").capitalize()
print (Order)
You need:
while Order not in FoodMenuList or Order not in DrinksMenuList:
if Order in FoodMenuList or Order in DrinksMenuList:
break
if Order not in FoodMenuList or Order not in DrinksMenuList:
Order = input ("Sorry, I Didn't Understand What You Said, Can You Repeat?\n").capitalize() # here
print (Order)
Also you can rewrite your program in way that there will be no repeated code, but it's your choice, heh.
Personally, I'd write something like this, because it's checking for being in menu in while
condition:
while Order not in FoodMenuList or Order not in DrinksMenuList:
Order = input ("Sorry, I Didn't Understand What You Said, Can You Repeat?\n").capitalize()
print (Order)
CodePudding user response:
My answer will seem a bit unpopular amongst the answers to this question. There is a syntax error in line
Order = input ("Here's Our Food Menu\n" FoodMenu "\nAnd Here's Our Drinks Menu\n" DrinksMenu "\nChoose What Serves You The Best.\n").capitalize
capitalize() is an attribute and not a characteristic of string data type hence it needs to be invoked with a parenthesis.
When the function is invoked without a parenthesis, a completely different element is stored in the variable "Order" which is why the code isn't relating to the keywords provided in FoodMenuList and DrinkMenuList