[Tutor] Question about conditions and empty values

Shelby Martin shelby.martin at gmail.com
Sat Oct 26 21:13:22 CEST 2013


For the program below, if I enter "0" at the prompt, it provides the reply
"Please, sit. It may be a while". However, if I just press the Enter key,
it shuts the program down without a reply from the Maitre D'.

My question is this - the author of this exercise states the condition is
False if either zero or "empty" is the value. I'm assuming he means that
empty is just pressing Enter without entering a number?

He talks about testing for empty values, but I'm not seeing that entering
an empty value here yields the response he is talking about. Unless I'm
mistaken about something. Thanks in advance for your assistance!

#Maitre D'
#Demonstrates treating a value as a condition

print("Welcome to the Chateau D' Food")
print("It seems we are quite full this evening.\n")

money = int(input("How many dollars do you slip the Maitre D'?"))

if money:
    print("Ah, I am reminded of a table. Right this way.")
else:
    print("Please, sit. It may be a while.")

input("\n\nPress the enter key to exit.")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131026/92c84a93/attachment.html>


More information about the Tutor mailing list