Hello, When my program runs and reaches the winning condition of else: it will print both from the if and else as well as subtract the 1 as if it was a losing value.
Need help with the order of operations.
an example of the outcome
Need help with the order of operations.
an example of the outcome
Output:what is your name?keys
Hello! keys
you rolled a 6
loser
your cash is 99
you rolled a 8
loser
your cash is 98
you rolled a 9
loser
your cash is 97
you rolled a 7
loser
your cash is 96
[color=#1ABC9C]you rolled a 11
loser
your cash is 95
you rolled a 11
winner!
your cash is 195[/color]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#dice game name = input ( "what is your name?" ) print ( "Hello!" ,name) import random die1 = random.randint( 1 , 6 ) die2 = random.randint( 1 , 6 ) total = die1 + die2 money = 100 while total < 10 : if total < 10 : die1 = random.randint( 1 , 6 ) die2 = random.randint( 1 , 6 ) total = die1 + die2 money - = 1 print ( "you rolled a" ,total) print ( "\tloser" ) print ( "your cash is" ,money) else : money + = 100 print ( "you rolled a" ,total) print ( "\twinner!" ) print ( "your cash is" ,money) |