I have to create a slot machine sort of in Python that displays numbers 0 - 5 and if the player gets a specific sequence of numbers they win a specific amount of money. I have created all the code to score the player and print it but I can't loop that block.
I want to start the loop from (if wants_play == "p" and player_score >= 0).
Here is my code:
import random
player_score = 1
round_score = 0
wants_play = input("Press 'P' to play or 'Q' to quit. ")
if wants_play == "p" and player_score >= 0:
print("you have " + str(player_score) + " pound")
num1 = random.randint(0, 5)
num2 = random.randint(0, 5)
num3 = random.randint(0, 5)
print("you got numbers:", num1, num2, num3)
round_score = 0
player_score = 0.2
if num1 == num2 or num1 == num3 or num2 == num3:
round_score = 0.5
if num1 == num2 and num1 == num3 and num2 == num3:
round_score = 1
if num1 == 0 and num2 == 0 and num3 == 0:
round_score = 5
if num1 == 1 and num2 == 1 or num1 == 1 and num3 ==1 or num2 == 1 and num3 == 1:
round_score = -1
if num1 == 1 and num2 == 1 and num3 == 1:
round_score = 0
player_score = 0
print("you won ", round_score, " pounds!")
player_score += round_score
if player_score < 0:
player_score = 0
else:
print("Goodbye")
exit()'''