0
use of input() in my own function
How do I use input in my own function? for example: >>> def f_input(): >>> player1=input("Player 1 choose \n") >>> player2=input("player 2 choose \n") How can i call 'player1' and 'player2' outside of the function?
2 Respuestas
+ 2
thanks both of you... really helpful!!!
+ 1
You can wrap them (player1 and player2) in a tuple and return it. Then f_input caller can use it.
def f_input():
player1 = input("Player 1")
player2 = input("Player 2")
return (player1, player2)
# main
players = f_input()
print(players, type(players))