We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,240 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Lucky Sevens game

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
aharrisii
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

ihatehippies
Junior Poster
197 posts since Oct 2008
Reputation Points: 33
Solved Threads: 16
Skill Endorsements: 1

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

woooee
Posting Maven
2,707 posts since Dec 2006
Reputation Points: 827
Solved Threads: 779
Skill Endorsements: 9

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

aharrisii
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

rny5
Newbie Poster
1 post since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0694 seconds using 2.71MB