+ 1
How can I print random elements in a list?
List = ["string", "word", "type"]
4 Antworten
+ 5
If you are looking to get more than 1 random element from an iterabe, you can use choices() instead:
from random import choices
lst = [2,4,11,9,5,2,8]
print(choices(lst,k=3)) # k is the number of elements to return by choices
+ 3
Import random
random.choice(List)
if this isn't what you are looking for ,let me know
+ 2
Abhay Thanks this is exactly what I was looking for
+ 1
https://code.sololearn.com/cuBqKS6TmrzB/?ref=app
You can check my project to know some more ...