[Tutor] Help with if-elif-else structure

Christopher King g.nius.ck at gmail.com
Thu Aug 25 17:23:40 CEST 2011


Looks good, although I would add one or two things.

> #assuming target number 15
>
Put that in a variable for the target number

> roll = (result, initial_mins, initial_max)
> if roll[0] > 15:
>    if roll[1] >= 2:

You could even put all the constants in variables

>

       print("Success")
>    elif roll[2] >= 2:
>        print("Critical failure!")
>    else:
>        print("Failure.")
> elif roll[0] <= 15:
>    if roll[1] >= 2:
>        print("Critical success!")
>    elif roll[2] >= 2:
>        print("Failure")
>    else:
>        print("Success")
>
Also need a couple comments, plus everything from the other emails.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110825/f756e29b/attachment.html>


More information about the Tutor mailing list