vendredi 3 février 2017

'if' statement for when two random numbers are equal

I am trying to have a situation in which when we toss two coins at the same, if we get heads on both coins we win and if we get tails on both coins we lose.

I have been able to generate the results of tossing one of the coins separately using:

def coin_one():
one = [random.randint(1, 100) for x in range(100)]
for x in one:
    if x <= 50:
        print('Heads')
    else:
        print('Tails')

and also for the second coin using basically the same method:

def coin_two():
two = [random.randint(1, 100) for x in range(100)]
for x in two:
  if x <= 50:
    print('Heads')
  else:
    print('Tails')

I am trying to add a condition that will print('win') if we have 'heads' in both coin_one and coin_two when the two coins are tossed at the same time. How do I do this?




Aucun commentaire:

Enregistrer un commentaire