mercredi 5 février 2020

How can I pick a random word in python from list for loop

Hello I am a learning python and my question is I have some words in a list I want to randomly select a word using a loop. Every time I run this code below it returns only random single letters like "y n d"

import random
import time

randomwords = ["my", "random", "words"]

for x in randomwords:
    time.sleep(1)
    print(random.choice(x))

how can I make the code return random order of the words like "words" "my" "random"




Aucun commentaire:

Enregistrer un commentaire