I want to do a conditional concatenation. My issue is at the end of the for-loop. I have all variables starting with \n
for removing this, and I need to strip out each variable. I think there should be a better way to handle this. Any suggestions would be appreciated.
foo = bar = remaining = ''
for i in ['foo', 'foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'el']:
if 'foo' in i:
foo += '\n%s' % i
elif 'bar' in i:
bar += '\n%s' % i
else:
remaining += '\n%s' % i
foo = foo.strip()
bar = bar.strip()
remaining = remaining.strip()