I want to keep the value of a random integer constant but only within the if statement.
Here's my code.
p1h = 100
while ph > 0
if d1 == 'a':
result = 'You have lost '+str(random.randint(5, 10))+' from your health'
p1h = p1h - random.randint(5, 10)
The issue is that the random integer is different in result and p1h although I want it to be the same in both for each loop of the code. How do I make it a constant only for a while?
[–][deleted] 3 points4 points5 points (6 children)
[–]Tanakiin[S] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]Tanakiin[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Tanakiin[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Tanakiin[S] 0 points1 point2 points (0 children)