jeudi 4 février 2021

Selecting a random list and then pulling information from that list

I know how to append and access random data from a list. I'm trying to randomize one of the Lists (A, B, or C), then use data from those lists.

Is it as simple as changing random_list to match the actual List_A (or b/c)? Or am I going about it all wrong?

import random

All_Lists = ["List_A", "List_B", "List_C"]
List_A = ["Albert", "Apple", "3", "Alpaca", "4"]
List_B = ["Barbara", "Banana", "6", "Baboon", "3"]
List_C = ["Calvin", "Carrot", "1", "Cat", "0"]

rand_idy = int(random.random() * len(All_Lists))
random_list = All_Lists[rand_idy]
print(random_list)



Aucun commentaire:

Enregistrer un commentaire