I am having an issue with writing functions to determine if firstly, something is in a list and secondly, in relation to the user having a bank balance.
Essentially what the function needs to do is, allow the user to use their balance to bet on a team and also check if the team they have typed in is in the list of teams.
This is what I have so far if anybody could help me with this. I feel like it may need to be one function for both but can't work it out and other threads have not helped me, thanks.
team_list = ["Team1", "Team2", "Team3"]
def Team():
team = input("Please choose a team to bet on.")
if team in team_list:
print("You have selected",team)
else:
print("That team is not in the list please select one in the list")
return Team()
def Stake():
bank = float(50.0)
stake = float(input("Please enter a stake"))
if stake <= bank:
print("Your bet has been placed.", stake, "on", team)
bank -= stake
print(bank)
else:
print("You don't have enough money to place this")
return Stake()
Team()
Stake()
teamvalue then use it later.teamandstakeas globals (but have not declared them as such, so it's not working), and you're also trying to return them (but only when recursing, so again it doesn't work). If you want them to be global, then declare themglobalinside the functions.