I have two lists *animal* and *fruit* and I try to get a random variable
animal or fruit and then random word from that list.
I thought that dictionary(*words*) could help me but no succes, the only way 
I've
done partially what was with list *kinds* and by using two times
random.choice. However print(kind) return me a list not a variable:
animal or fruit so now I'm kinda confuse if I can achieve that.



import random
animal = ['koala', 'kangaroo']
fruit = ['banana', 'apple']
kinds = [animal,fruit]
words = {'animals': animal, 'fruits': fruit}


kind = random.choice(kinds)
print(kind)
word = random.choice(kind)
print(word)
#output:
['kolala', 'kangaroo']
kangaroo

--
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to