Here is what I am trying to do:
Pick a random word from a list
Ask the user of a word to replace it with
Print out the list with the word replaced
So I have the random word picker part finished, but I don't know how to replace the word with the input. I thought I could use the .replace() function, but it's a list. Here is the code:
import random
all_lists = ['beans','peaches','yogurt','eggs','pizza']
for x in all_lists:
print(x)
appending_list = input("Would you like to replace a word? Yes or No?")
if appending_list == ("Yes"):
random = random.choice(all_lists) #this picks the random word
replace_word = input("What would would you like to replace the word with?")
all_lists_replace = all_lists.replace(random, replace_word)
print(all_lists_replace)
if appending_list == ("No"):
exit()