How can I keep the change to any list when I use my function? Censor Dispenser

https://www.codecademy.com/practice/projects/censor-dispenser
As you can see I have the negative_words list, but obviously I want it to work on any list I put in.

negative_words = ["concerned", "behind", "danger", "dangerous", "alarming", "alarmed", "out of control", "help", "unhappy", "bad", "upset", "awful", "broken", "damage", "damaging", "dismal", "distressed", "distressing", "concerning", "horrible", "horribly", "questionable"]

def handle_up_low(lst_of_wrds): #my function
  new_lst = []
  for word in lst_of_wrds:
    new_lst.append(word.title())
    new_lst.append(word.upper())
    new_lst.append(word)
  lst_of_wrds = new_lst
  return lst_of_wrds
print(handle_up_low(negative_words))#prints out altered version
print(negative_words)#prints out original version

How can I keep the changes made to negative_words, or any list?

Maybe something like this?

new_storage_variable = handle_up_low(negative_words)

That’s a cool idea, but instead of making a new_storage variable maybe something like this?
lst = handle_up_low(lst)
Mmm, but I wish there was a way to make the changes stick. It would be kind of annoying having to do that everytime.

Tea, but I don’t recommend naming it the same thing

new_lst = handle_up_low(lst)

Yeah, and I usually wouldn’t, it’s just the function was made to alter the original list, so I didn’t have to do extra work in making sure my censor functions handle upper and title case words.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.