Python Tutorial, Release 3.9.5 Strings can be concatenated (glued together) with the$_{+}$operator, and repeated with$_{*}$ : Two or more string literals (i.e. the ones enclosed between quotes) next to each other are automatically concatenated. This feature is particularly useful when you want to break long strings: This only works with two literals though, not with variables or expressions: If you want to concatenate variables or a variable and a literal, use$_{+}$ : >>> prefix +'thon' 'Python' Strings can be indexed (subscripted), with the first character having index 0. There is no separate character type; a character is simply a string of size one: Indices may also be negative numbers, to start counting from the right: Note that since -0 is the same as 0, negative indices start from -1. In addition to indexing, slicing is also supported. While indexing is used to obtain individual characters, slicing allows you to obtain substring: >>> word[-1] # last character 'n' >>> word[-2] # second-last character 'o' >>> word[-6] 'P' >>> word ='Python' >>> word[0] # character in position 0 'P' >>> word[5] # character in position 5 'n' >>> prefix ='Py' >>> prefix 'thon' # can't concatenate a variable and a string literal File "<stdin>" , line1 prefix 'thon' ^ SyntaxError: invalid syntax >>> ('un'*3)'ium' File "<stdin>" , line1 ('un'*3)'ium' ^ SyntaxError: invalid syntax (continues on next page) Chapter 3. An Informal Introduction to Python 12 >>> word[0:2] # characters from position 0 (included) to 2 (excluded) 'Py' >>> text =('Put several strings within parentheses' ... 'to have them joined together.') >>> text 'Put several strings within parentheses to have them joined together.' >>> # 3 times 'un', followed by 'ium' >>> 3*'un'+'ium' 'unununium' >>> 'Py''thon' 'Python'