hello, its me again :-)

the_2nd_coming jpetzold at twmi.rr.com
Tue May 22 21:11:53 EDT 2001


thanks to all who have helped me with this simple little program.

I have finally gotten rid of all the errors, however, now I am getting a 
value of none returned.

the source is :
---------------------------------------------------------

def evaluate(list):
        num1 = int(list[0])
        num2 = int(list[2])
        operator = list[1]
        
        if operator == '+':
                answer = num1 + num2
        elif operator == '-':
                answer = num1 - num2
        elif operator == 'X':
                answer = num1 * num2
        elif operator == 'x':
                answer = num1 * num2
        elif operator == '*':
                answer = num1 * num2
        elif operator == '/':
                answer = num1 / num2
        else:
                print 'invalid operator'
        
def fix_expression(list):
        word = list
        l = []
        n1 = word[0]
        n2 = word[1]
        n3 = word[2]
        l.append(n1)
        l.append(n2)
        l.append(n3)
        evaluate(l)
        
# - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - 
import string
expression = raw_input('please enter your singel operator expression')
string.strip(expression) # get rid of all leading and trailing white space#
list = string.split(expression)

if len(list) >1:
        print evaluate(list)
elif len(list) == 1:
        print fix_expression(list[0])
         
else:
        import sys
        sys.exit
===================================================================

now what have I missed?!!

I really appreciate every thing that you-all have done.
this community is really a helpful one

thanks

J



More information about the Python-list mailing list