Last active
May 26, 2022 16:00
-
-
Save mdpabel/aa782b74c885fe5ef36fc88befb2e6e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution: | |
| def isNumber(self, s: str) -> bool: | |
| isFloat = False | |
| for char in s: | |
| if char == "." or char == "e" or char == "E": | |
| isFloat = True | |
| break | |
| try: | |
| if isFloat: float(s) | |
| else: int(s) | |
| return True | |
| except: | |
| return False | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment