+

Addition for numbers, concatenation for sequences — same symbol, two jobs.

Arithmetic operatorPython 1.0+Live demo
Common call
2 + 3
Returns
sum (numbers) or concatenation (sequences)
Replaces
"a" + "b" works; "a" + 1 raises TypeError
Watch out
int + float promotes to float
aaLeft operand.type: number | sequence · required + bbRight operand — must match a: number with number, sequence with same-type sequence.type: number | sequence · required
number | sequence

Demo

Live evaluation
Try:
Inputs
afloatleft operand
bfloatright operand
Output
2 + 3
5

Numeric addition, with the usual float caveat on display: 0.1 + 0.2 shows the stored binary result. In real Python the same symbol also concatenates strings and lists — see Examples.

Operands

NameTypeRequiredDescription
anumber | sequenceyesLeft operand.
bnumber | sequenceyesRight operand — must match a: number with number, sequence with same-type sequence.

Return value

number | sequenceThe sum of two numbers — or, for sequences of the same type (str, list, tuple), their concatenation.

Common patterns

Accumulate in place
a += b is the augmented form (calls __iadd__ when available).
total += price
Concatenate sequences
Same-type sequences join; mixing types raises.
[1, 2] + [3]      # [1, 2, 3]
"ab" + "cd"       # 'abcd'

Examples

1. Numbers
2 + 3
Returns
5
2. Float promotion
2 + 0.5
Returns
2.5
3. String concatenation
"ab" + "cd"
Returns
'abcd'
4. List concatenation
[1, 2] + [3]
Returns
[1, 2, 3]

Pitfalls

1. str + int raises
Python never implicitly converts between strings and numbers.
Raises
"age: " + 21
TypeError: can only concatenate str (not "int") to str
Fix
f"age: {21}"  # or "age: " + str(21)
'age: 21'
2. Repeated string + in a loop is quadratic
Each + copies the whole accumulated string.
Slow
out = ""
for s in parts:
    out = out + s
O(n²) copying
Fix
out = "".join(parts)
O(n)

When to use

Use it
  • Numeric addition
  • One-off concatenation of two sequences
Reach for something else
  • Joining many strings → str.join
  • Appending to a list → list.append / extend
  • Summing an iterable → sum()

Notes

Complexity
O(1) numbers; O(len(a)+len(b)) sequences
Return
new object; operands untouched
CPython impl
Objects/abstract.c :: PyNumber_Add → __add__ / __radd__
Memory
Concatenation allocates the combined sequence
Thread-safe
Yes — operands are not mutated

FAQ

It calls a.__add__(b), falling back to b.__radd__(a). Implement those to overload it.

History

1.0
Core operator from the beginning.