Solving anti-vowel using pop


I am using pop method to delete the element from the list. However , I am not able to remove the last element. Can any one explain why?

FAQ: Learn Python - Practice Makes Perfect - censor

please include your code? So we can actually replicate the problem and come up with a solution

i generally advise against use del, remove and pop. Using this approach gives problems like you experience (not being able to remove last element from list), which should make your question if you shouldn’t have gone for a different approach in the first place


Here we go.

def replace(text,word):

a = text.split()

for i in a:

if i == word:



replace('he he he ',‘he’)


You are creating a new string, removing from anything won’t bring you closer to that
Keep in mind that positions of elements in a list when you remove elements, how does that affect your loop?


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