No problem, welcome to the forums!
Yes, usually if you say
if x, as long as x exists, it will evaluate as
True. In this case semantically I thought it made sense consider how bits are 1s and 0s.
List item If I’m understanding you correctly, it’s actually my use of == that is resulting in me always returning the losing message result? This is because the statement is never going to be true while it’s set up using ==?
Not really. What I’m saying is that these statements don’t result in either a value being modified or a value being printed. The overall action is that the computer will evaluate them, but you won’t know about it for all it’s worth.
1 == "Heads"
# no output. 1 remains the same, "Heads" remains the same.
@dickykitchenjr One way to do this (but not the only way)
flip = random.randint(1, 2)
if flip == 1:
flip = "heads"
flip = "tails
List item If I want to keep track of the money won/loss, I need to create another function that will handle that aspect of the game.
Not necessarily. In a started program, you have have variables like you did with
money = 100.
The only change is that your win condition would not only return a string, but also a modification to player_1 score.
In a slightly more involved program you would probably have player class. But that’s a different topic.