Can i create a logical operator that says true when something is logically right like: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can i create a logical operator that says true when something is logically right like:

If i have bread and there is a specific place that i store bread but for some reason it's stored on a "counter" and not on the specific place then everytime i ask if the bread is in the specific place the answer would be true but if it's not there and it's on the counter the code will say false. -->Let's name the specific place a "cabinet" : I am just curious to know

10th Aug 2020, 7:11 PM
DeadEye UNT
DeadEye UNT - avatar
3 Answers
+ 3
counter = [] cabinet = ['bread'] if 'bread' in cabinet: print('I\'ll get it for you!') elif 'bread' in counter: print('Here you are!') else: print('Sorry, we\'re out of bread.')
10th Aug 2020, 8:00 PM
HonFu
HonFu - avatar
+ 3
Yes. Just frame condition properly to get correct result Your description has some confusing as @Slick asked.. How your are going determine where it is..? It is upto how you frame it.. I use variables to store info: if bread_placed == "cabinet" : return true else : return false
10th Aug 2020, 7:33 PM
Jayakrishna 🇮🇳
+ 1
How can the bread be on the counter if its not there?
10th Aug 2020, 7:20 PM
Slick
Slick - avatar