dimanche 11 avril 2021

Dice game add a payment method

I have this code and I want to add a payment method to make the person start with 6$. Each time the dice roll if they are equal you add the sum of the dice to the guy's money; if they are not equal you subtract 2.

import random
a = random.randrange(1 , 6)
b = random.randrange(1 , 6)
print (a , b)
if a == b:
    print("you win" , 2 + a + b)
else:
    print("you lose")

Trial code that almost worked but is highly stupid:

import random
a = random.randint(1 , 2)
b = random.randint(1 , 2)
print (a , b)
e = 1
g = 1
for x in range(g):
    e = 6
    g = e/2
    if a == b:
        print("you win")
        e = a + b + e 
        
    else:
        print("you lose" )
        e = e - 2
    print(e)



Aucun commentaire:

Enregistrer un commentaire