[Tutor] Crazy craps problem

col speed ajarncolin at gmail.com
Sun Oct 9 09:01:58 CEST 2011


<-->  snip
>>         if point(one+two) == "win":
>>
>
> Here you go into the function "point" the first time. Inside the function
> you are in an infinite while-loop where you only exit if the sum is either 7
> ("lose") or equal the given parameter ("win"). Then you compare the return
> value. In the case of "lose" you continue to the next elif-statement:
>
>
>              stake += bet*2
>>             print winmsg
>>         elif  point(one+two) == "lose":
>>
>
> Now you go into the function "point" a *second* time, in other words you
> have to throw another 7 to leave the function with the return value "lose".
> But just now you will print out the message for loosing the game:
>
>
>              print losemsg
>>             player = changePlayer(player)
>>
>
> What you probably want is to go into "point" only once, save the result
> value and check if it's "win" or "lose".
>
> HTH,
>
> Andreas
>
>
Amazing as always. I will act upon all suggestions.
Thanks again
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111009/1bf7120e/attachment.html>


More information about the Tutor mailing list