forked from lpr014/omega
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputParser.py
More file actions
28 lines (28 loc) · 834 Bytes
/
InputParser.py
File metadata and controls
28 lines (28 loc) · 834 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
def inputParser():
word=''
inString=[]
string=raw_input('\ninput: ').strip()
for char in string:
if char.isdigit() or char=='.':
word+=char
elif char.isdigit()==False:
if char.isalpha():
return('invalid input character')
try:
print(word)
if word.isdigit():
inString+=[float(word)]
except:
return('invalid input')
word=''
inString+=[char]
try:
inString+=[float(word)]
except:
None #None for fact to work
for i in range(len(inString)-1):
if inString[i]=='/' and inString[i+1]=='/':
inString[i]='//'
inString[i+1]='//'
inString=inString[:i]+inString[i+1:]
return(inString)