I want to let user enter string such as 2+5-3+6
and return 10
. If user enter c
then answer will be printed. I don't know how to make the project break when user enter a c
.
print 'This is a calculator. Please follow the instruction.'
temp = 0
string = 0
def asmd(string):
print 'Your answer is', eval(str(string))
while temp != 'c':
print 'Please enter a number or operation. Enter c to complete. :'
temp = raw_input()
string = str(string)+str(temp)
if temp == str('c'):
asmd(string)