Im trying to create a simple program that has list keys, and multiple list values for each. Im getting confused on the differences between lists, dictionaries and libraries.
How do I group multiple lists into a MAIN list to have users choose from?
example:
import random
#lists to describe what trucks people like
person= ['I', 'she', 'he']
emtotion=['loves', 'hates', 'likes']
Trucks= ['chevys', 'fords', 'rams']`
#lists to describe an animals favorite foods
animal= ['dogs', 'cats', 'birds']
emotion_2=['love', 'hates']
food= ['tuna', 'meat', 'seeds', 'garbage']
for the lists above, how do i group the TWO seperate lists of three lists into 2 seperate master type lists? example:
# a main call to describe peoples emotions towards trucks
truck_preference =
person= ['I', 'she', 'he']
emtotion=['loves', 'hates', 'likes']
Trucks= ['chevys', 'fords', 'rams']
#a main call for all lists describing an animals foods
animal_foods=
animal= ['dogs', 'cats', 'birds']
emotion_2=['love', 'hates']
food= ['tuna', 'meat', 'seeds', 'garbage']
so for example, once i have my TWO main categories, I can ask a user for input to select "animal_foods" or "truck_preference" and randomly display the values to form a string of text, a simple 3 word random text. then ask the user to select a list again, this time "animal_foods" and display the same randomness again.
this is what I have now, to print the random items.
count = 0
while count < 10:
print(random.choice(Person), end= " ")
print(random.choice(Emotion), end= " ")
print(random.choice(Trucks), end= " " )
print('\n')
count = count +1
count = 0
while count < 10:
print(random.choice(animal), end= " ")
print(random.choice(Emotion_2), end= " ")
print(random.choice(Food), end= " " )
print('\n')
count = count +1
But, my biggest problem is how to ask a user to select either the "Truck_preference" to print the items randomly to form the random texts and and then ask the user to select the "animal_foods" list values to form random text about that.
so what Id hope to accomplish summed up is:
import random
truck_preference = [3 key lists and their values]
animal_foods =[3 key lists and their values]
input("which scenario would you like to run")
#user inputs Truck_preference
output: I love chevys
he likes fords
she hates rams
he loves rams
i like fords
....etc
input("which scenario would you like to run")
#user inputs animal_foods
output: Cats hate seeds
dogs love meat
dogs hate meat
birds hate tuna
cats love tuna
birds love seeds
dogs love garbage
...etc
Aucun commentaire:
Enregistrer un commentaire