Why is Python adding input numbers as strings instead of integers? When I enter 2 and 3, the output is 23 instead of 5

2 weeks ago 17
ARTICLE AD BOX

a = input("Enter first number: ")

b = input("Enter second number: ")

print(a + b)

asked 3 mins ago

jasmeet's user avatar

New contributor

jasmeet is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1

The '+' operator applied to two strings is string concatenation and not arithmetic addition. Cast each string to an integer: print((int(a) + int(b)).

2025-11-27 18:58:17 +00:00

Commented 1 min ago

Read Entire Article