this may seem odd, trying remove part of item contained in list. basically, trying remove specific character multiple list elements. example
list = ['c1','c2','c3','d1','s1'] list.remove('c')
i know doing wouldn't work, there way remove "c"s in list, , "c"s in python 3?
lst = [s.replace('c','') s in lst] # ['1','2','3','d1','s1']
list comprehensions friend. note "list" keyword in python, highly recommend do not use variable name.
Comments
Post a Comment