import random

money = 0
finmoney = 0
turns = 0
colturns = 0
finturns = colturns + turns
print("""
1
2
3
4
5
6
7
8
9
10

red
black

every guess = - 1$

every colour = - 5$

every correct = + 10

The goal is to get to 100$
""")

while money != 100:

gamble = random.randint(1,10)
redblack = random.randint(1,2)

cho = input("""

colours or numbers: """)

#COLOURS, the less annoing testing

if cho == ("colours"):
    col = input("what colour are you betting on: ")

    if col == ("red"):
        if redblack == 1:
            finturns = finturns - 1
            money = money + 10
            finmoney = 5 * finturns + 10                
            print("it took you", finturns, "attempts to get it right")
            print("you made", finmoney, "$")
            finturns = -1


    if col == ("black"):
        if redblack == 2:
            finturns = finturns - 1
            money = money + 10
            money = 5 * finturns
            print("it took you", finturns, "attempts to get it right")
            print("you made", money, "$")
            finturns = -1

    else:
        finturns = finturns - 1
        money = money -5

#NUMBERS, the annoing stuff

if cho == ("numbers"):
    num = int(input("what number are you betting on: "))

    if num == 1:
        if gamble == 1:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 2:
        if gamble == 2:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 3:
        if gamble == 3:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 4:
        if gamble == 3:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 5:
        if gamble == 5:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 6:
        if gamble == 6:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", turns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 7:
        if gamble == 7:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 8:
        if gamble == 8:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right") 
            print("you lost", money)
            gamble = random.randint(1,10)
            finturns = 0


    if num == 9:
        if gamble == 9:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0

    if num == 10:
        if gamble == 10:
            finturns = finturns + 1
            money = money - 1
            print("""you gained 10 dollars!
                  """)
            money = money + 10
            print("it took you", finturns, "attempts to get it right")
            print("you made", money)
            gamble = random.randint(1,10)
            finturns = 0



    else:
        turns = turns + 1
        money = money - 1
JamesCherrill commented: Not Java -3

Recommended Answers

All 5 Replies

if someone guesses the wrong question i want it to ask "what number are you betting on" not "colours or numbers", im gonna clean up the code later just proof of theory right now. also im a newbie dont judge

Is this java or python and why did you tag the question as both?

While I do not know if this is quite what you have in mind, I do think the code can be improved upon substantially. For a start, roulette wheels generally have slots with both a color and a number, and you have to get both right to pay off.

import random

money = 0
finturns = 0
print("""
1
2
3
4
5
6
7
8
9
10

red
black 

every guess = - 1$
every colour = - 5$
every correct = + 10
The goal is to get to 100$
""")

while money < 100:
    print(f"Your current bank is ${money}.")
    col = input("what colour are you betting on: ")
    num = int(input("what number are you betting on: "))

    finturns += 1
    gamble = random.randint(1,10)
    redblack = "red" if random.randint(0,1) == 0 else "black"
    print(f"{redblack}-{gamble}, ", end='')    

    if redblack == col and gamble == num:
        print("Player wins!")
        print("you gained 10 dollars!")
        money += 10
        print(f"it took you {finturns} attempts to win.")
        finturns = 0

    else:
        print(f"House wins.")
        money -= 1

roulette wheels generally have slots with both a color and a number, and you have to get both right to pay off

Each number is red or black according to a fixed pattern: "In number ranges from 1 to 10 and 19 to 28, odd numbers are red and even are black. In ranges from 11 to 18 and 29 to 36, odd numbers are black and even are red." (WikiPedia).
So a bet in a number is implicitly a bet on a colour and still only gets the 1:36 odds
Conversely a bet on a colour is independent of the number and gets a 1:2 payout.
(Strictly speaking with one or two zeros the odds are 1:37 or 1:38 for numbers, 18:37 or 18:38 for colours.)

commented: Oh, I didn't know that. My apologizes. +15
commented: How close is the 1:2 since there's that one green slot. +16

How close is the 1:2 since there's that one green slot.

Like I said, with one zero its 18:37 (ie 1:2.055). With 2 zeros its 18:38 (1:2.111)

commented: "This house always wins." +0
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.