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)

Recommended Answers

All 4 Replies

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.

You should also check for values between a certain range, i.e. someone can not enter one million or a letter.

import random

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.