I’m trying to create a string that has a set amount of different words I include in a list, however the code I use only uses one word at random, not a different word for every word printed.
This is my code:
import random
words = ['hello', 'apple', 'something', 'yeah', 'nope', 'lalala']
print random.choice(words) * 5
An example output would be:
hellohellohellohellohello
An example expected output would be:
appleyeahhellonopesomething
Can anyone tell me what I’m doing wrong?
random.choice(words) * 5executesrandom.choiceonly once and then multiplies the result by five, causing the same string to be repeated.