lundi 30 janvier 2017

How to tell that the strings selected randomly out of a list are the same

I have this question; I'll sum it up in steps

  1. Make the program add 7 animals to a list via inputs (DONE)
  2. Make the program select 3 random animals from that list (DONE)
  3. If the animals selected are all the same, print 'Bingo!' ; if not, loop the input until the user presses 'X' or gets a 'Bingo!'.

I'm having trouble with the last step, and I've tried searching everywhere and tried many methods but the code isn't doing the right thing. Here's the code:

import random

bingoList=[]
generatedList=[]

def generateCards():
    for i in range(0,3):   
        print(random.choice(bingoList))
        generatedList.append(a)

for i in range(0,7):
    a=input("Enter an animal: ")
    if (a.isdigit()==False):
        bingoList.append(a)
    else:
        printprint("You are not allowed to input numbers; program stopping...")
        exit()

print("All the animals have been stored, let's start the game..")

generateCards()




Aucun commentaire:

Enregistrer un commentaire