Name | + (addition) |
||||
---|---|---|---|---|---|
Examples |
a = 50 + 5 # Sets 'a' to 55 b = a + 5 # Sets 'b' to 60 s1 = "Chernenko" s2 = "Brezhnev" sc1 = s1 + s2 sc2 = s1 + ", Andropov, " + s2 print(sc1) # Prints "ChernenkoBrezhnev" print(sc2) # Prints "Chernenko, Andropov, Brezhnev" s1 = "Gorbachev" i = 1987 sc1 = s1 + str(i) print(sc1) # Prints "Gorbachev1987" | ||||
Description | Adds two values or concatenates string values. As a mathematical operator, it calculates the sum of two values. As a string operator, it combines two strings into one. Note that for concatenation, non-string datatypes must be cast to strings using str(). | ||||
Syntax | value1 + value2 | ||||
Parameters |
| ||||
Related |
+= (add assign) - (minus) |
Updated on Mon Sep 21 15:53:24 2020.
If you see any errors or have comments, please let us know.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License