[Tutor] Giving a name to a function and calling it, rather than calling the function directly

R. Alan Monroe amonroe at columbus.rr.com
Sun Sep 5 00:24:31 CEST 2010


>     if coinToss(1,2) == 1:
>         heads += 1
>         tossNo += 1
>     else:
>         tails += 1
>         tossNo += 1

Looking good. You can hoist "tossNo += 1" out of each branch of your if
statement too, if you like, to make it even more streamlined (In
other words, execute it once, right after the coin flip, and before
the if-statement).

Alan



More information about the Tutor mailing list