I have to program a simple calculator, i had all of my functions working seperatly but now that they are all together the add and the average won't compute. The problems started when i tried to get the program to loop back to the menu after you get a total. Any help would be greatly appreciated. i tried to upload my code but it failed so i just added it on to this post. thanks for the help!

print" welcome to python calculator"
print
print" choose an option:"
print
print"1 add"
print"2 subtract"
print"3 Multiply"
print"4 divide"
print"5 mod"
print"6 average"
print"7 exit"
menuchoice = raw_input("make your selection from the menu-->")
menuchoice = raw_input("please make a selection")

if menuchoice =="1":
sum = 0.0
number = 1
while number !=0:
print "Enter 0 to exit loop"
number = input("Enter a number: ")
if number !=0:
sum = sum + number
print "equals: ", sum + number
elif menuchoice =="2":
integer1 = raw_input( "enter first integer: \n")
integer1 = int(integer1)
integer2 = raw_input( "enter second integer: \n")
integer2 = int(integer2)
difference = integer1 - integer2
print" Difference is \a ",difference
elif menuchoice =="3":
integer1 = raw_input( "enter first integer: \n")
integer1 = int(integer1)
integer2 = raw_input( "enter second integer: \n")
integer2 = int(integer2)
product = integer1 * integer2
print" Product is \a ",product
elif menuchoice =="4":
integer1 = raw_input( "enter first integer: \n")
integer1 = int(integer1)
integer2 = raw_input( "enter second integer: \n")
integer2 = int(integer2)
quotient = integer1 / integer2
print" Quotient is \a ",quotient
elif menuchoice =="5":
integer1 = raw_input( "enter first integer: \n")
integer1 = int(integer1)
integer2 = raw_input( "enter second integer: \n")
integer2 = int(integer2)
mod = integer1 % integer2
print" Mod is \a ",mod
elif menuchoice =="6":
count = 0
sum = 0.0
number = 1
print "Enter 0 to exit the loop"
while number !=0:
number = input("enter a number:")
if number !=0:
count = count + 1
sum = sum + number
print "The average was:",float (sum) / count

Why is there no indentation at all? This. Is. Madness!

for Python on Daniweb:
Please use the [code=python] and [/code] tag pair to enclose your python code.

Also read:
http://www.daniweb.com/forums/announcement114-3.html

further:
look at the light gray message in the post entry field for the forum

I made a few modifications to your code, used functions and a loop, test it out ...

# simple calculator

def menu():
    print '-'*40
    print" welcome to python calculator"
    print
    print" choose an option:"
    print
    print"1 add"
    print"2 subtract"
    print"3 Multiply"
    print"4 divide"
    print"5 mod"
    print"6 average"
    print"7 exit"
    menuchoice = raw_input("make your selection from the menu --> ")
    #menuchoice = raw_input("please make a selection")
    return menuchoice

def calc(menuchoice):
    if menuchoice =="1":
        sum = 0.0
        number = 1
        while number !=0:
            print "Enter 0 to exit loop"
            number = input("Enter a number: ")
            if number !=0:
                sum = sum + number
        print "equals: ", sum + number
    elif menuchoice =="2":
        integer1 = raw_input( "enter first integer: \n")
        integer1 = int(integer1)
        integer2 = raw_input( "enter second integer: \n")
        integer2 = int(integer2)
        difference = integer1 - integer2
        print" Difference is \a ",difference
    elif menuchoice =="3":
        integer1 = raw_input( "enter first integer: \n")
        integer1 = int(integer1)
        integer2 = raw_input( "enter second integer: \n")
        integer2 = int(integer2)
        product = integer1 * integer2
        print" Product is \a ",product
    elif menuchoice =="4":
        integer1 = raw_input( "enter first integer: \n")
        integer1 = int(integer1)
        integer2 = raw_input( "enter second integer: \n")
        integer2 = int(integer2)
        quotient = integer1 / integer2
        print" Quotient is \a ",quotient
    elif menuchoice =="5":
        integer1 = raw_input( "enter first integer: \n")
        integer1 = int(integer1)
        integer2 = raw_input( "enter second integer: \n")
        integer2 = int(integer2)
        mod = integer1 % integer2
        print" Mod is \a ",mod
    elif menuchoice =="6":
        count = 0
        sum = 0.0
        number = 1
        print "Enter 0 to exit the loop"
        while number !=0:
            number = input("enter a number:")
            if number !=0:
                count = count + 1
                sum = sum + number
        print "The average was:",float (sum) / count

# the program loop
while True:
    menuchoice = menu()
    if menuchoice == "7":
        break
    calc(menuchoice)
This question has already been answered. Start a new discussion instead.