On 26/10/13 20:13, Shelby Martin wrote:

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?

Normally that would be correct but...


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

Here we try to convert the string to an int. and int() fails
when given an empty string so your program never reaches the
if test.

Which begs the question: GHOw are you running your programs?
If you used a console or an IDE it should have shown you the error message which would have explained what and where things went wrong.

You would need to either use a try/except clause around the conversion or check for an empty string before converting. try/except is the preferred route but you may not have covered that yet.

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

If you did get the error message then please, in future, include
any such in their entirety in posts because they greatly simplify diagnosing more complex issues.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to