I have an odd problem. I am attempting to create a quote generator that has a dictionary of sections of a quote (each value is a list), pulls a random item from that list for each key and appends that to another list. That list will then be printed to show the final quote.
However, I am getting the quote's sections in a random order. When running, I get something like this:
['avoid ', 'hobby.', "it's easy to ", 'your ', 'Occasionally ', 'most important ']
Here's my code:
from random import choice
quoteWords = {
"one": ["Sometimes ", "Often ", "Occasionally ", "Usually "],
"two": ["it's best to ", "you should ", "you shouldn't ", "it's easy to ", "it's hard to "],
"three": ["do ", "avoid ", "finish", "create ", "witness "],
"four": ["the ", "a ", "your ", "society's ", "your friends' ", "the government's "],
"five": ["best ", "most important ", "funniest "],
"six": ["work.", "art.", "hobby.", "posessions."],
}
def inspire():
quote = []
counter = 0
for key in quoteWords:
quote.insert(counter, choice(quoteWords[key]))
counter += 1
return(quote)
print(inspire())
Any help would be greatly appreciated. Thanks in advance!