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
value1String, int, float, char, byte, boolean
value2String, int, float, char, byte, boolean
Related += (add assign)
- (minus)
Updated on Tue Jul 11 06:52:23 2017.
Creative Commons License