Spaces:
Running
Running
Upload isNumber.py
Browse files- isNumber.py +22 -0
isNumber.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[1]:
|
5 |
+
|
6 |
+
|
7 |
+
# Function to check if the string is a number
|
8 |
+
def is_number(x):
|
9 |
+
if type(x) == str:
|
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 |
+
|