Getting a default value on index out of range in Python
In the non-Python spirit of "ask for permission, not forgiveness", here's another way:
b = a[4] if len(a) > 4 else 'sss'
In the Python spirit of "ask for forgiveness, not permission", here's one way:
try:
b = a[4]
except IndexError:
b = 'sss'