-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnumbr.py
48 lines (36 loc) · 854 Bytes
/
numbr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def numbers_sort(exp):
digit='.0123456789'
symbols='//**-+%^!'
n=''
i=0
while i < len(exp):
if exp[i] in digit:
n+=exp[i]
elif exp[i] == ' ':
i+=1
continue
elif exp[i] in symbols:
if exp[i+1] in digit:
n+=' '
elif exp[i+1] in symbols:
n+=' '
i+=1
elif exp[i+1] == ' ':
n+=' '
i+=1
continue
else:
n=0
break
i+=1
if n!=0:
num_str=n.split(' ')
num=[]
for i in num_str:
if '.' in i:
num.append(float(i))
else:
num.append(int(i))
return num
else:
return 0