Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Put random generated string into a list

+1 vote
asked Apr 23 by QuiiKy _ (420 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.
...