On 03/05/13 17:51, Nonso Ibenegbu wrote:

The second function breaks down when the argument is 7 or above.

Yet the only difference is that the condition "if days >= 7:" comes
first in the first function but comes second (as "elif days >= 7:") in
the second code.

Yes but that's because the other expression is nonsense (to python).

You cannot write

if days >= 3 < 7:

It doesn't make any sense.

What you mean is

if days >=3 and days < 7

If you fix that then the two functions will have similar logic.

In Python 9unlike most languages) you can abbreviate that but not the way you did it.
You need to use

if 3 <= days < 7:

Note that the variable is in the middle and the test for 3
is now reversed (3<=days). If in doubt use the double test
combined by 'and' as above.



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

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

Reply via email to