yanhua <gasf...@163.com> writes:

> it's a simple question:
> input two integers A and B in a line,output A+B?
>
> this is my program:
> s = input()

input() is probably not what you think it is. Check raw_input instead.

> t = s.split()
> a = int(t[0])
> b = int(t[1])
> print(a+b)
>
> but i think it's too complex,can anybody tell to slove it with less code.

print sum(map(int,raw_input().split()))

or replace sum by reduce. BTW, it works with any number of integers

You can find this by walking backwards in your code, starting at a+b,
and generalizing a little bit on your way.

-- Alain.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to