I’m an absolute beginner but this simple part of my cointoss program has been driving me a bit mad. Whenever I input ‘heads’, it still returns 0 outside the function… what am I doing wrong? I also acknowledge there are premade functions that can probably do all of this much more efficiently. I’m just trying to get my hands dirty so to speak. See code below, thanks!
def coinpick(playerpick): coinchoice = input ("...and up it goes! Heads or Tails?\n").lower() if coinchoice == "heads": print ("\nOk") playerpick = 1 print (playerpick) return playerpick elif coinchoice == "tails": print ("\nAlright") playerpick = 0 print (playerpick) return playerpick else: print ("\nWay to mess up a simple cointoss. Let's try this again...") coinpick() coinpick(playerpick) test = input("Playerpick was " + str(playerpick)) print (test)