python - Take out punctuation within a word -


i have function takes parameters punctuation symbol , list of words. function looks in each word , splits punctuation. example:

["i...love", "you"] ---> ["i","love","you"] 

the problem using so-called "incomprehensible list comprehension" it, , exhibiting strange behaviour:

def take_out(symbol, word_list):         word in word_list:             if symbol in word , "http" not in word :                 word_list[word_list.index(word)] = (" ".join([x x in word.split(symbol)])).split()         word_list = [[item] if isinstance(item, str) else item item in word_list]         word_list = [item sublist in word_list item in sublist]         return word_list 

can suggest way of accomplishing task without using nebulous approach have.

if understand question correctly, try this:

z = [] in ["i...love","you"]:     j in i.split("..."):         z.append(j) print(z) 

hope helps!


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -