python - paper rock scissor - Global Variable? -
why not working? need assign global variables? it's saying player1
not defined!
options=["p", "s", "r"] def valid1(): validationa = true while validationa==true: player1=input("player 1.. take go") if player1 not in options: print ("invalid") else: validationa==false return player1 def valid2(): validationb = true while validationb==true: player2=input("player 2.. take go") if player2 not in options: print ("invalid") else: validationb==false return player2 valid1() valid2() if player1=="p" , player2 =="p": print("draw") else: print("works unfinished")
your functions return values, never assign them anything.
player1 = valid1() player2 = valid2()
in fact, these functions exact same thing, if make text either dynamic or more generic have single function , call twice
player1 = valid() player2 = valid()
Comments
Post a Comment