2 ms·
Some of the simpler list comprehensions (like the student one two parents up) are fairly "symbol soup" free, though - and a very clean way of expressing what yo
by angusgr 16y ago
Some of the simpler list comprehensions (like the student one two parents up) are fairly "symbol soup" free, though - and a very clean way of expressing what you want.
OTOH, I can see how they could still be a hard concept for a beginner who hasn't done any functional programming before, particularly because they don't read front-to-back like most imperative statements.
EDIT: You can always split complex ones up as well, for most common usages:
meeps = [ s for s in str_list if s[:4] == 'meep' ]
suffix_str_lst = ['{0}_suffix'.format(m) for m in meeps ]
This one was probably a bit simple to really need that, but it's a bit easier to read. :).
- deleted 16y ago[deleted]