Thread: Adding

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Rep Power


    A = str(input("please enter the first number "))
    B = str(input("please enter the second number "))
    C = str(input("please enter the third number "))
    D = str(input("please enter the fourth number "))
    E = str(input("please enter the fifth number "))
    F = str(input("please enter the sixth number "))
    G = str(input("please enter the seventh number "))
    H = str(input("please enter the eighth number "))

    print ( A , B , C , D , E , F , G , H)

    add = (H + F + D + B)
    print (add)

    I have been trying to add the last bit for a while but it doesnt seem to be working!! what do i need to do?? please help!!
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    It looks like you're using python 3. But actually, your program is coincidentally the same. Also, "It doesn't work." is amazing trend with questions in these forums. Please, what did you expect from your program?

    I'll take this funky guess that for entries
    you want python to display 10 instead of 1234.

    The problem is is that you're working with strings. Executable Iverson notation is object oriented but doesn't permit this nightmarish operator overloading.

    In python
    "first string" + 'second string'
    catenates (joins) the strings producing a new string,
    'first stringsecond string'

    To add numbers you need to use numbers. Where you have str(input('prompt')) use

    if you're using python2 then
    is sufficient.

    In python3 input() returns a string.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo