Spaces:
Sleeping
Sleeping
Update isNumber.py
Browse files- isNumber.py +9 -22
isNumber.py
CHANGED
|
@@ -1,22 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
x = x.replace(',', '')
|
| 11 |
-
try:
|
| 12 |
-
float(x)
|
| 13 |
-
except:
|
| 14 |
-
return False
|
| 15 |
-
return True
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
# In[ ]:
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 1 |
+
# Function to check if the string is a number
|
| 2 |
+
def is_number(x):
|
| 3 |
+
if type(x) == str:
|
| 4 |
+
x = x.replace(',', '')
|
| 5 |
+
try:
|
| 6 |
+
float(x)
|
| 7 |
+
except:
|
| 8 |
+
return False
|
| 9 |
+
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|