
report at bugs
Nov 24, 2009, 11:19 PM
Post #2 of 2
(161 views)
Permalink
|
|
[issue7393] Executing Python program of sum of 2 nos.
[In reply to]
|
|
Raymond Hettinger <rhettinger [at] users> added the comment: In Python 3.1, the input() function always returns a string. In your case, the string is "21". Adding two strings together gives you a longer string: "12" + "34" --> "1234". To get your program to do what you want, convert the string to a number using int(): a = int(input('give a number: ')) b = int(input('and another: ')) print('the sum is', a + b) ---------- nosy: +rhettinger resolution: -> invalid status: open -> closed _______________________________________ Python tracker <report [at] bugs> <http://bugs.python.org/issue7393> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
|