I am having trouble correcting the syntax on this problem so far and I can't seem to find my mistake any ideas on what I am doing wrong ? The object of the program is to ask user for amount of money to put in the pot, and play until the pot is empty.
import random
mypot = int(input("Please enter the amount of money you want in the pot: "))
diceroll1 = random.randit(1, 7)
diceroll2 = random.randit(1, 7)
myrole = (diceroll + diceroll2)
if myrole == 7:
print("Your roll was a 7 you eaerned: ", mypot + 4)
else:
print("Your roll was not a seven you lost: ", mypot - 1)
4
Contributors
4
Replies
19 Hours
Discussion Span
1 Year Ago
Last Updated
5
Views
Related Article:Lingo game in Python
is a Python discussion thread by carmstr4 that has 4 replies, was last updated 1 year ago and has been tagged with the keywords: game, python.
Hard to check your syntax unless you put your code in code blocks because we can't see the indents. Change 'random.randit' to 'random.randint' x 2. Change 'myrole = (diceroll + diceroll2)' to
'myrole = (diceroll1 + diceroll2)'
As written this will not play until the pot is empty. Consider adding
while mypot > 0:
# code here
a little proofreading will solve a lot of your problems.
mypot = int(input("Please enter the amount of money you want in the pot: "))
diceroll1 = random.randint(1, 7)
diceroll2 = random.randint(1, 7)
myrole = (diceroll1 + diceroll2)
while mypot > 0:
if myrole == 7:
print("Your roll was a 7 you eaerned press enter to roll again: ", mypot + 4)
break
else:
print("Sorry you did not roll a 7 press enter to roll again: ", mypot - 1)
break
how can i get the loop to repeat until my pot == 0
"break" stops your loop, without it your loop will run until mypot <= 0. That's btw the next problem, the value for mypot doesn't change and it will loop for a long long time.