concatenation
Joining two strings or two lists end to end with +, as in "Hello, " + name.
In more detail
Both sides must be the same kind of sequence: "Age: " + 30 raises TypeError, so convert with str() or use a format string instead. Concatenation builds a new object; list append changes an existing list.
Example
"ab" + "cd" # "abcd"Related terms
- string — A sequence of characters, that is, a piece of text.
- repetition — Making a longer string or list by repeating one with *, as in "-" * 10.
- TypeError — The exception raised when an operation or function gets a value of the wrong type, such as adding a number to a string.
- append() — A list method that adds one item to the end of the list, changing the list in place.
Taught in
- A Sample Program, Explained — Hands-on Python: Complete Video Course & Book
- Strings, Delimiters And Concatenation — Hands-on Python: Complete Video Course & Book
- Variables And Assignment — Hands-on Python: Complete Video Course & Book
- Input, And Numbers Versus Digits — Hands-on Python: Complete Video Course & Book
- Appending To Lists, Sets, Constructors — Hands-on Python: Complete Video Course & Book