Make code More pythonic