Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
October 25th, 2012, 07:53 AM
 tania.joseph
Registered User

Join Date: Oct 2012
Posts: 1
Time spent in forums: 46 m 46 sec
Reputation Power: 0

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)

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
October 25th, 2012, 11:25 AM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,217
Time spent in forums: 1 Month 3 Weeks 2 Days 18 h 34 m 45 sec
Reputation Power: 455
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
1
2
3
4
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
float(input('prompt'))

if you're using python2 then
input('prompt')
is sufficient.

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

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Adding