Andy
Champion of the Sun
I'm relatively new at programming, and Python is my first language so please take that into consideration before you read on.
Right, I am trying to create a Roulette type of game in Python. It asks for a number between 0 and 36, or it asks for you to place a bet on it being an odd or even number. This is the bet the user is making. It then generates a random number between 0 and 36.
What I need to do, is for the program to check if the bet is an integer or not, and if it is, see if it matches the random number that was made. If it does, you have won and it should say "Big Winner". If it isn't right, then it should display something like "Sorry, you have won nothing".
BUT, if the user inputted "odd" as their bet, it should check to see if it is an odd or even number. If it's odd, it should give them the message "Little Win". (So if they guess if the random number generate is odd or even correctly, they win).
However, I'm stuck on how to go about doing this. As I have said, I am quite new to programming, and have only been able to do the following code:
[HIGHLIGHT=python]
import random
randomnumber = random.randrange(0,36)
print randomnumber
bet = raw_input("Please enter either a number between 0 and 36, or choose 'odd' or 'even'")
def roulette():
odd = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35]
even = [2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34]
if int(bet) == randomnumber:
print "Big Winner"
elif int(bet) != randomnumber:
print "Unlucky, you have won nothing"
if randomnumber == odd:
if bet == "odd":
print "Congrats"
roulette()[/HIGHLIGHT]
That's how far I have gotten, but I know it's wrong. Should I create another function or something? Thanks in advance to anyone who helps =)
Right, I am trying to create a Roulette type of game in Python. It asks for a number between 0 and 36, or it asks for you to place a bet on it being an odd or even number. This is the bet the user is making. It then generates a random number between 0 and 36.
What I need to do, is for the program to check if the bet is an integer or not, and if it is, see if it matches the random number that was made. If it does, you have won and it should say "Big Winner". If it isn't right, then it should display something like "Sorry, you have won nothing".
BUT, if the user inputted "odd" as their bet, it should check to see if it is an odd or even number. If it's odd, it should give them the message "Little Win". (So if they guess if the random number generate is odd or even correctly, they win).
However, I'm stuck on how to go about doing this. As I have said, I am quite new to programming, and have only been able to do the following code:
[HIGHLIGHT=python]
import random
randomnumber = random.randrange(0,36)
print randomnumber
bet = raw_input("Please enter either a number between 0 and 36, or choose 'odd' or 'even'")
def roulette():
odd = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35]
even = [2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34]
if int(bet) == randomnumber:
print "Big Winner"
elif int(bet) != randomnumber:
print "Unlucky, you have won nothing"
if randomnumber == odd:
if bet == "odd":
print "Congrats"
roulette()[/HIGHLIGHT]
That's how far I have gotten, but I know it's wrong. Should I create another function or something? Thanks in advance to anyone who helps =)