One Line 'If' or 'For'...
- by aTory
Every so often on here I see someone's code and what looks to be a 'one-liner', that being a one line statement that performs in the standard way a traditional 'if' statement or 'for' loop works.
I've googled around and can't really find what kind of ones you can perform? Can anyone advise and preferably give some examples?
For example, could I do this in one line:
example = "example"
if "exam" in example:
print "yes!"
Or:
for a in someList:
list.append(splitColon.split(a))