lundi 27 juin 2016

How to select an integer randomly from a list containing integers as well as other objects?

I have a list

data=['_','_','A','B','C',1,2,3,4,5]

I need to randomly get an integer among 1,2,3,4,5 The list keeps getting modified so i cant just simply choose from the last 5 members

Here's what i tried but it throws an error retrieving the other members:

inp2=int(random.choice(data))




Aucun commentaire:

Enregistrer un commentaire