My code runs perfectly and with the results that I want. However, the last print ("Anxious: ") is NOT outputting Anxious: but instead only printing out the answer without the title.
I have run this multiple times in IDLE 3.10.1 as well as my Python I online class’s own Python program and I get the exact same result. Absolutely no errors but no title either after the last print statement.
Does anyone have an idea of what is going on? I have not had this kind of problem before in my previous code that I ran for my online class.
Thank you!
busy = True
hungry = False
tired = True
stressed = False
happy = busy and not stressed
sad = hungry or tired
print("Happy: " + str(happy))
print("Sad: " + str(sad))
print("Confused: "+ str(happy and sad))
print("Bored: " + str(not(happy or sad or busy)))
print("Anxious: " + str(not happy) and (not sad) and (not stressed))
>Solution :
It’s just a logic error:
busy = True
hungry = False
tired = True
stressed = False
happy = busy and not stressed
sad = hungry or tired
print("Happy: " + str(happy))
print("Sad: " + str(sad))
print("Confused: "+ str(happy and sad))
print("Bored: " + str(not(happy or sad or busy)))
print("Anxious: " + str(not happy and (not sad) and (not stressed)))
This:
print("Anxious: " + str(not happy) and (not sad) and (not stressed)))
Should be:
print("Anxious: " + str(not happy and (not sad) and (not stressed)))
#or
print("Anxious: " + str((not happy) and (not sad) and (not stressed)))