-
-
Save jennie8902/cca2bbb8c95d86fd63355bfb024bef6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
money = 100 | |
all_nums = range(1,37) | |
green = ["0", "00"] | |
red = [1, 3, 5, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36] | |
black = [2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35] | |
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, 36] | |
bottom_third = range(1, 13) | |
middle_third = range(13, 25) | |
top_third = range(25, 37) | |
bottom_half = range(1, 19) | |
top_half = range(20, 37) | |
first_column = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34] | |
second_column = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35] | |
third_column = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36] | |
string_all_nums = [str(all_num) for all_num in all_nums] | |
all_digits = string_all_nums + green | |
string_red = [str(reds) for reds in red] | |
string_black = [str(blacks) for blacks in black] | |
string_odd = [str(odds) for odds in odd] | |
string_even = [str(evens) for evens in even] | |
string_bottom_third = [str(bthird) for bthird in bottom_third] | |
string_middle_third = [str(mthird) for mthird in middle_third] | |
string_top_third = [str(tthird) for tthird in top_third] | |
string_bottom_half = [str(bhalf) for bhalf in bottom_half] | |
string_top_half = [str(thalf) for thalf in top_half] | |
string_first_column = [str(fcolumn) for fcolumn in first_column] | |
string_second_column = [str(scolumn) for scolumn in second_column] | |
string_third_column = [str(tcolumn) for tcolumn in third_column] | |
options = ["red", "black", "green", "even", "odd", "1 to 12", "13 to 24", "25 to 36", "1 to 18", \ | |
"19 to 36", "first column", "second column", "third column"] | |
while True: | |
your_choice = input("What would you like to bet on? ").lower() | |
while your_choice not in string_all_nums and your_choice not in green and your_choice not in options: | |
print("Invalid choice.") | |
your_choice = input("What would you like to bet on? ") | |
while True: | |
try: | |
bet = int(input("What is your bet? ")) | |
if bet <= 0 or bet > money: | |
raise ValueError | |
break | |
except ValueError: | |
print("Invalid bet.") | |
spin = random.choice(all_digits) | |
if your_choice in all_digits: | |
if your_choice == spin: | |
money += bet * 35 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice != spin: | |
money -= bet | |
print("You spun a " + str(spin) + ". You lose! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
if money == 0: | |
print("You are out of money.") | |
break | |
if your_choice in options: | |
if your_choice == "red" and spin in string_red: | |
money += bet | |
print("You spun a red " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "red" or your_choice == "green" and spin in string_black: | |
money -= bet | |
print("You spun a black " + str(spin) + ". You lose! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
if money == 0: | |
print("You are out of money.") | |
break | |
elif your_choice == "black" or your_choice == "green" and spin in string_red: | |
money -= bet | |
print("You spun a red " + str(spin) + ". You lose! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
if money == 0: | |
print("You are out of money.") | |
break | |
elif your_choice == "red" or your_choice == "black" and spin in green: | |
money -= bet | |
print("You spun a green " + str(spin) + ". You lose! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
if money == 0: | |
print("You are out of money.") | |
break | |
elif your_choice == "black" and spin in string_black: | |
money += bet | |
print("You spun a black " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "green" and spin in green: | |
money += bet | |
print("You spun a green " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "odd" and spin in string_odd: | |
money += bet | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "even" and spin in string_even: | |
money += bet | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "1 to 12" and spin in string_bottom_third: | |
money += bet * 2 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "13 to 24" and spin in string_middle_third: | |
money += bet * 2 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "25 to 36" and spin in string_top_third: | |
money += bet * 2 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "1 to 18" and spin in string_bottom_half: | |
money += bet | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "19 to 36" and spin in string_top_half: | |
money += bet | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "first column" and spin in string_first_column: | |
money += bet * 2 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "second column" and spin in string_second_column: | |
money += bet * 2 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
elif your_choice == "third column" and spin in string_third_column: | |
money += bet * 2 | |
print("You spun a " + str(spin) + ". You win! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
else: | |
money -= bet | |
print("You spun a " + str(spin) + ". You lose! You now have " + str(money) + " coins.") | |
if money > 0: | |
keep_playing = input('Play again? ') | |
if keep_playing.lower() == "yes": | |
print("Let's continue.") | |
else: | |
print("Thanks for playing!") | |
break | |
if money == 0: | |
print("You are out of money.") | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment