I'm trying to make a very simple and kinda archaic Rock-paper-scissors game, with only to player and to be run through the console.
I have something like this:
def rps():
player_hand = input('>_')
machine_hand_opt = ['rock', 'paper', 'scissors']
machine_hand = random.choice(machine_hand_opt)
who_win = machine
if machine_hand == 'rock' and player_hand == 'scissors':
who_win
return who_win
elif clown_hand == 'rock' and player_hand == 'paper':
who_win = 'user'
return who_win
This is only part of the code, and you can imagine the remaining. As you can see, the machine hand is chosen randomly from a list, I use the variable 'who_win' to get who wins and then print something, but when the result is printed, the user only knows it's own hand, and not machine's hand, because the functions only returns who wins, is obviously simple to figure out machine's hand if player wins or loose, but I think this is a good chance to know how to print variables outside functions. It would be something like:
print("Player's hand:", player_hand)
print("Machine's hand:", machine_hand)
Any ideas?