+ 1
How do i fix this code? ):
Sorry for the nooby question but i'm looking for someone to tell me what i have done wrong, I'm trying to get this code to output the print statement for haribo and snickers when only entering those two into the input but instead it prints the top one (Haribo, snickers and crisps) even though i only entered haribo and snickers and did not enter crisps. I'm totally new to all of this so sorry again https://code.sololearn.com/cyJQW9N75NG3/#py
3 odpowiedzi
+ 1
Braiden Parsons if order == 'haribo' and ... and... how can a variable be equal to three values,
So correct your conditions like:
if order == "haribo, snickers and crisps":
elif order == "haribo and snickers"
But user would have to type the whole sentence so shorten it by using numbers,
You can simplify your program by this:
order = input("1. Haribo\n2.Snickers\n3.Crisps\n4. Haribo and Snickers\n5. Haribo and Crisps\n6. Snickers and Crisps\n 7. All three.\n Enter a number: ")
Now the conditions would be easy like,
if order == '1':
...
elif order == '2':
+ 1
Oh god, I'm such a doofus. Thank you! I did think about the numbers thing before but i wasn't 100% sure how to do it correctly. Thanks again for the help!
+ 1
Braiden Parsons lol no problem, it happens to everyone.