List = [[1,2,3],[4,5,6],[7,8,9]]
i want to pick a random element in List
and return the index of it.
when I do:
List.index(random.choice(List[random.randint(0,2)]))
it obviously gives me an error, because the code only indexes the list-elements in List
.
what I would like to have is something like:
output: The random number is: 4 and the index is: (1,0) or List[1][0]
Aucun commentaire:
Enregistrer un commentaire