Python Forum
How do you create a true/false response?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you create a true/false response?
#1
Hello,

I am trying to create an accurate output (below snapshot is not giving me what I need) when I trigger the user to type in the meals they had 24 hours ago like: meat, chocolate, dairy. The output should say False for meat and everything else true but I am not getting that - can someone help me?

Input
menu = '"seafood, dairy, nuts, chocolate"'
input_test = input("enter food categories eaten in the last 24 hours: ").lower()
print('It is',"dairy" in input_test.lower(),"that",menu,'contains',"dairy")
print('It is',"nuts" in input_test.lower(),"that",menu,'contains',"nuts")
print('It is',"seafood" in input_test.lower(),"that",menu,'contains',"seafood")
print('It is',"chocolate" in input_test.lower(),"that",menu,'contains',"chocolate")

Output
enter food categories eaten in the last 24 hours: meat, seafood, nutS
It is False that "seafood, dairy, nuts, chocolate" contains dairy
It is True that "seafood, dairy, nuts, chocolate" contains nuts
It is True that "seafood, dairy, nuts, chocolate" contains seafood
It is False that "seafood, dairy, nuts, chocolate" contains chocolate
Reply


Messages In This Thread
How do you create a true/false response? - by adamgobin - Jan-07-2018, 11:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  HELP - Writing code returning True or False Kokuzuma 2 2,802 Nov-01-2018, 03:37 AM
Last Post: Kokuzuma

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020