Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python's PRINT is not outputting the last print() word

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading