humble coin head or tail game script I wrote

sjdevnull at yahoo.com sjdevnull at yahoo.com
Fri Oct 6 16:58:15 EDT 2006


Camellia wrote:
> Well...It' doesn't, have you run it yet?

Yes it does, and running it reflects that behavior.

> ini_guess = random.randrange(1)
> list_guess = ['t', 'h']
> ini_guess = list_guess[ini_guess]

random.randrange(1) will always return 0, so this will always
initialize ini_guess to 't'

> for item in list:
>     if item == ini_guess:
>         correct += 1
>     elif item == 'h':
>         ini_guess = 't'
>     elif item == 't':
>         ini_guess == 'h'

If item was 't', then correct is incremented and nothing else happens.
ini_guess remains 't'.
If item was 'h', ini_guess will be set to 't'.

The final "elif item=='t':" branch will never be executed.




More information about the Python-list mailing list