Hi
I just have one question, I’m just doing a project in python after flow control, what It did it’s working and I found I can’t use input function in the web for enter data.
So this is my code, what recommendation will you give me to improve what I did?
import random
money = 100 # This variable will measure if the money is more or les
# I will create my functions below
# Function to make a new call and new flip
def coin_call():
coin = ('Heads', 'Tails')
coin = random.choice(coin)
print(coin)
return coin
def coin_flip():
flipresult = ('Heads', 'Tails')
flipresult = random.choice(flipresult)
print(flipresult)
return flipresult
# Flipping coin game
def coin_game(call, bet,flip):
global money
if call == 'Heads' and flip == 'Tails':
money -= bet
print("you just lost " + " your current balance is: " + str(money) + " USD")
elif call == 'Heads' and flip == 'Heads':
money = money + bet
print("you just won " + " your current balance is: " + str(money) + " USD")
elif call == 'Tails' and flip == 'Heads':
money = money - bet
print("you just lost " + " your current balance is: " + str(money) + " USD")
elif call == 'Tails' and flip == 'Tails':
money = money + bet
print("you just won " + " your current balance is: " + str(money) + " USD")
# Calling my functions with values for coin flip exercise
while money > 0:
bet = 50
if bet <= money and bet > 0:
coin_game(coin_call(),bet,coin_flip())
elif bet > money:
print('You aint got that ammount')
break
else:
print('you cant bet negative numbers')
break