Put random generated string into a list

0 votes
asked Apr 23 by QuiiKy _ (410 points)
So I have a

Example = 'hi',''hello,''no"

random.choice(Example)

and want to put that choice into a list:

inventory = ["hi"]

1 Answer

+1 vote
answered Apr 26 by MK (240 points)

There you go:

import random

Example = ["hi","hello","no"]
Inventory = []
Inventory.append(random.choice(Example))


print(Inventory)

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...