I have tried to figure this out on my own forever now. I have been getting hint from the net but can't figure it out. So I figured I would admit defeat and see what you guys could show me. I need the three numbers entered into this program to add together, as of right now they aren't adding. The numbers are just showing up. EDIT: I AM A NOOB AT PROGRAMMING

def main():


    print("Adding:")
a = input("Please select a number:")
b = input("And another one:")
c = input("One more please:")
d = a+b+c
print(d)



main()

Edited 4 Years Ago by KY_Fan

Which numbers? I only see you taking three string input and then concatenating them, assuming you are using python3 as indicated by form of your print statements. No use to define a function for only one print call.

I have to input a random number each time it asks (After I run the code). Then instead of giving me the sum of the three random numbers I put in, it just displays the three random numbers. Where I am knew to this stuff it is kind of difficult for me to explain and my professor is a loser and won't help!! lol

def add():
    a = input("Please select a number: ")
    b = input("And another one: ")
    c = input("One more please: ")
    return float(a) + float(b) + float(c)


print("Adding:")
print(add())

Edited 4 Years Ago by pyTony

Wooo! Thanks for showing me the proper code. I just can't believe I took this online CS course and professor is horrible. He doesn't help at ALL and he only gives us a day or so per assignment. Considering this is an intro to CS class you would think we would have more time! I am going to try and reconnect with one of my high school teachers that knows how to code.

This is really a question of what version of Python you are using.
If you use Python2 then input() is for numeric input, but with Python3 you will get strings.

With Python27 this will work:

# Python27

def main():
    print("Adding:")
    a = input("Please select a number:")
    b = input("And another one:")
    c = input("One more please:")
    d = a+b+c
    print(d)


main()

'''possible result ...

Adding:
Please select a number:1
And another one:2
One more please:3
6

'''

Edited 4 Years Ago by sneekula

Well I am using Python3. I guess that is why I was having so much trouble, I'm not sure what my version of Python my book is using either. I guess I need to read up some more..

Thanks for the help!

This question has already been answered. Start a new discussion instead.