Untitled
unknown
plain_text
2 years ago
1.8 kB
7
Indexable
import random
# Define the pockets on the roulette wheel
pockets = {
'0': 'green',
'00': 'green',
'1': 'red',
'2': 'black',
'3': 'red',
'4': 'black',
'5': 'red',
'6': 'black',
'7': 'red',
'8': 'black',
'9': 'red',
'10': 'black',
'11': 'black',
'12': 'red',
'13': 'black',
'14': 'red',
'15': 'black',
'16': 'red',
'17': 'black',
'18': 'red',
'19': 'red',
'20': 'black',
'21': 'red',
'22': 'black',
'23': 'red',
'24': 'black',
'25': 'red',
'26': 'black',
'27': 'red',
'28': 'black',
'29': 'black',
'30': 'red',
'31': 'black',
'32': 'red',
'33': 'black',
'34': 'red',
'35': 'black',
'36': 'red'
}
# Function to simulate spinning the roulette wheel
def spin_roulette_wheel():
return random.choice(list(pockets.keys()))
# Function to determine the color of the pocket
def get_pocket_color(pocket_number):
return pockets.get(pocket_number, 'unknown')
# Function to play the roulette game
def play_roulette():
print("Welcome to the roulette game!")
while True:
print("Place your bet on a number (0-36) or 'q' to quit:")
bet = input()
if bet == 'q':
print("Thanks for playing!")
break
if bet not in pockets.keys():
print("Invalid bet. Please try again.")
continue
pocket_number = spin_roulette_wheel()
pocket_color = get_pocket_color(pocket_number)
print("Spinning the roulette wheel...")
print("The ball landed on pocket", pocket_number)
if bet == pocket_number:
print("Congratulations! You won!")
else:
print("Sorry, you lost. The pocket color is", pocket_color)
print()
# Start the game
play_roulette()
Editor is loading...