Im wondering if:
s = 'foo bar'
a, b = s.split(' ')
print(a)
'foo'
print(b)
'bar'
so why:
s = 'foo bar'
a, b = s.split(' ') if s else '',''
print(a)
['foo', 'bar']
print(b)
''
Can someone explain me why python behaves like shown at the second example?
Thank you!
Aucun commentaire:
Enregistrer un commentaire