Purify


#1

Can anybody tell me why does my code return [2,2] while it should return [2] ?

def purify(numbers):
  list=[]
  new_list=[]
  for number in numbers:
    list.append(number)
    for i in list:
      if(i%2==0):
        new_list.append(i)
  return new_list

print(purify([1,2,3]))

#2

using replace() is no challenge, it allows for a single line solution

you need to replace the word with an equal amount of asterisks, so if you need to censor the you need to replace it with ***

its more fun to design your own solution then depending on a built-in function


#4

every time you append to list, you loop over list as well, this will cause way too many append to new_list

i don’t see the point of list = [], given you can just loop over numbers, see if the number is even, append to new_list if that is the case


#6