-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods.py
More file actions
32 lines (29 loc) · 811 Bytes
/
Copy pathmethods.py
File metadata and controls
32 lines (29 loc) · 811 Bytes
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
import re
def convertText(textToConvert):
charList = list(textToConvert)
number1=[]
number2=[]
if charList[0] == '-':
number1.append(charList[0])
index = 1
else:
index = 0
while charList[index] not in ['+','-','*','/']:
number1.append(charList[index])
index+=1
sign = charList[index]
index+=1
if charList[index] == '-':
number2.append(charList[index])
index+=1
while index< len(charList):
number2.append(charList[index])
index+=1
number1 = ''.join(number1)
number2 = ''.join(number2)
return [number1, sign, number2]
def verifyText(_text):
if _text.isnumeric() or re.findall("(-)|(\d+\.?\d*) |([+-/*])|(\d+\.?\d*)",_text):
return _text
else:
return ''