I'm trying to figure out the syntax for passing arguments from one list or dict to another in the for loop syntax.
The desired result I'm looking for is this:
for bean in beans:
if bean.type == 'coffee':
print bean
Only, instead of printing to stdout, I'd like to collect that string data and append it to another list. Eventually flattening the list.
The kicker, I want to perform this in a single line.
I know of the ''.join()
method, I'm looking for this result so I can filter the results from the for-in loop.