Q: How can i choose just one value from this list with random lib? Hello i want to randomly choose just 1 value from Animal key anyone can help me?
import random

dict = {

    "Animals": ["Elephant", "Lion", "Snake"]
}

a1 = random.choice(list(dict.values()))

print(a1)

this outputs whole value part. how can i make python just randomly choose 1 of them

A: Try this,  list(dict.values()) -> [["Elephant", "Lion", "Snake"]] this will convert the dict values to list of list so when you are chosing values you are get one list as answer in your case only single list is created so you are getting that list only
import random

dict_ = {

    "Animals": ["Elephant", "Lion", "Snake"], "Plants": ["abc", "def"]
}

a1 = random.choice(sum(dict_.values(), []))
print(a1)

