Login dark
class Solution:
    def myAtoi(self, str: str) -> int:
        ret = ''
        start = False
        for i in str.strip():
            if start:
                if i.isnumeric():
                    ret += i
                else:
                    break
            else:
                if '+' == i or '-' == i or i.isnumeric():
                    ret += i
                    start = True
                else:
                    return 0
        if ret in ['+','-','']:
            return 0
        else:
            return min(max(int(ret),-2 ** 31),2 ** 31 -1)