What is wrong in my code of these addition of two numbers (Python 3)

While I was trying this addition problem (first practice problem that comes up on this site), I faced a problem.

The problem was to add two numbers.

So I typed:

A = input(“enter number A”)
B = input(“enter number B”)
print(int(str(A)) + int(str(B)))

It said that this method was wrong.

The answer, however, was this:
#Read the number of test cases.
T = int(input())
for tc in range(T):
# Read integers a and b.
(a, b) = map(int, input().split(’ '))

ans = a + b
print(ans)

I didn’t quite understand this code. Could some explain this to me?

Didn’t understand the map part

There must have been mentioned in the question that there has to be taken the number of test cases, which is T in this case. And for loop is used to repeat the program for T times.

‘map’ is a keyword used for mapping. Here it is used so that multiple values can be allotted to multiple variables in a single line.

Now, a and b will get inputs in a single line like we can enter:
1 2
instead of
1
2
in your previous case.

Hope you understand. If not just tell me and I will try telling you more. :blush: