Skip to content

Instantly share code, notes, and snippets.

@mdpabel
Last active May 26, 2022 16:00
Show Gist options
  • Select an option

  • Save mdpabel/aa782b74c885fe5ef36fc88befb2e6e4 to your computer and use it in GitHub Desktop.

Select an option

Save mdpabel/aa782b74c885fe5ef36fc88befb2e6e4 to your computer and use it in GitHub Desktop.
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