File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ def parse(expression):
93
93
result .append (i )
94
94
else :
95
95
raise Exception ("invalid syntax " + i )
96
-
96
+
97
97
if len (current ) > 0 :
98
98
result .append (current )
99
99
return result
@@ -133,15 +133,17 @@ def main():
133
133
simple user-interface
134
134
"""
135
135
print ("\t \t Calculator\n \n " )
136
- user_input = input ("expression or exit: " )
137
- while user_input != "exit" :
136
+ while True :
137
+ user_input = input ("expression or exit: " )
138
+ if user_input == "exit" :
139
+ break
138
140
try :
139
141
print ("The result is {0}" .format (evaluate (user_input )))
140
142
except Exception :
141
143
print ("invalid syntax!" )
142
144
user_input = input ("expression or exit: " )
143
145
print ("program end" )
144
-
146
+
145
147
146
148
if __name__ == "__main__" :
147
149
main ()
You can’t perform that action at this time.
0 commit comments