## Definition To combine [[string|strings]] end-to-end, forming a new single string. *Verb. Noun form: concatenation.* > We concatenate three strings to create the username—forename, surname, and `str(class_year)`. ## Characteristics - An operation on strings; - combines two or more strings into one new string; - uses the `+` operator in Python; and - does not automatically insert spaces between the composite strings. ## Examples ### Concatenating two string literals ```python inane_greeting = "hello" + " " + "world" # "hello world" correct_greeting = "greetings" + " my " + "liege" # "greetings my liege" ``` ### Concatenating string variables ```python a = "hello" b = "world" inane_greeting = a + " " + b # "hello world" ``` ## Non-examples ### `print(a, b)` Printing values separated by commas does not concatenate them. ```python a = "hello" b = "world" print(a, b) # not concatenation print(a + " " + b) # concatenation ``` ### f-strings [[f-strings]] do not inherently use concatenation. ```python a = "hello" b = "world" inane_greeting = f"{a} {b}" # not concatenation ``` But they can (don't do this, it's gross): ```python a = "hello" b = "world" inane_greeting = f"{a + ' ' + b}" # gross concatenation ```