# -*- coding: cp1252 -*-
"""TP1 P79: ZCasino"""
from random import*
from math import ceil


def color(nb):
    if nb%2==0:
        return 'Black'
    else:
        return 'Red'


def Game(bet,result):
    if result==51:
        print("first attempt")  
    else:
        print("You had to choose:",result)       
    print("You have:",bet,"$")
    if bet==0:
        return "plucked"
    play=input("do you want to play? Yes/No")
    if play=='No':
        print("Wise decision","you leave with",bet,"$")
    elif play=='Yes':
        gamble=input("What number do you choose?")
        gamble=int(gamble) #Number you bet on
        col=color(gamble)
    result=randrange(50)
    
    if result==gamble:
        return Game(3*bet,result)
    elif color(result)==col:
        return Game(ceil(0.5*bet),result)
    elif gamble>50:
        print("wrong choice")
    else:    
        return Game(0,result)
    
        
        
def Roulette():
    account=input("Amount you start with:")
    try:
        account=int(account) #Converts account from str to int
        assert account>0 #otherwise, don't play
    except ValueError:
        print("didn't enter a number!!")
    except AssertionError:
        print("won't go far with this amount of money!")

    return Game(account,51)
