I'm currently trying to create sort of a poker game were you input an int (how many rounds to play) then have both Human and Computer generate cards based on the int you put and decide who wins for each round. My question is how do I return an argument from a function into another function? I have the x, y in function poker()
that I want to use to compare in function totalwins()
.
import random
Deck = ['Diamond', 'Hearts', 'Jack', 'Spade']
Number = [1,2,3,4,5,6,7,8,9,10,11,12]
def poker(x,y):
Times = int(input('How many rounds would you like to play: '))
while Times > 0:
Human = random.choice(Deck)
Human_value = random.choice(Number)
Computer = random.choice(Deck)
Computer_value = random.choice(Number)
print('Human: ', Human , Human_value)
print('Computer: ', Computer, Computer_value)
if Human_value > Computer_value:
print('Human wins')
x +=1
elif Human_value < Computer_value:
print('Computer wins')
y += 1
else:
print('Tie')
Times -= 1
poker(0,0)
def totalwins():
if x > y:
print('Human wins!')
else:
print('Computer wins!')
totalwins()