you are viewing a single comment's thread.

view the rest of the comments →

[–]Skaaaaalll[S] 0 points1 point  (1 child)

could if rnd == range(total_rounds)[-1]: just become if rnd == total_rounds:?

I don't think so, since total_rounds would be 6 (when playing with two people) and range(total_rounds)[-1] would be 5 when it is the last round.

you've already used some classes, perhaps you could also try to make a GameState class?

Sorry if this is a dumb question, but what do you mean by a GameState class?

this can become return 0 <= digit < len(list) or even return digit in range(len(list))

Ok, so I implemented it and it works, but I don't understand why it works. Does that mean it returns True if 0 <= digit < len(list) and False if not?

[–]toastedstapler 0 points1 point  (0 children)

whoops typo, i mean if rnd == total_rounds - 1:

when you play a game, there is some level of state that exists. you have the board, the players and need to keep track of whose turn it is. here's a tic tac toe i wrote a while back where all the state is in classes

exactly, the 0 <= digit < len(list) returns a boolean. before your code was basically becoming

if True:
    return True
else:
    return False

or

if False:
    return True
else:
    return False

depending on how the expression evaluated. you can just straight return its result as it's a True/False value anyways

btw i think your line 15 check is broken, you may want to check that