Is it possible to bypass an if statement when delimiting a list that has both a presence and absence of a ‘,’ delimiter? I would like to delimit each list in this the list of list below when a ‘,’ is present. However, some of the lists don’t have a ‘,’.
oldcode = [['a, b'], ['a'], ['a,b,c']]
oldcode_split = []
for code in oldcode:
oc = code.split(',')
oldcode_split.append(oc)
print oldcode_split
I would like this result:
oldcode_split = [['a','b'], ['a'], ['a','b','c']]
Thanks!
yes it is possible, use a simple list comprehension:
using
map():