

You can also access the characters in the opposite direction starting from -1, which means you can also use -1 as an index value to access. which is the 16th character in the string. In the string above, the first index is C and it is indexed 0. Strings are indexed with respect to each character in the string and the indexing begins at 0: Since strings are a sequence of characters, you can access it through slicing and indexing just like you would with Python lists or tuples. You can find the length of a string using the built-in len() function: len(triple_quote_new) This is triple quoted string using 'single' quotes. Triple_quote_new = triple_quote + "'single'" + triple_quote TypeError: 'str' object does not support item assignment TypeError Traceback (most recent call last)ġ triple_quote = '''This is triple quoted string using "single" quotes.''' triple_quote = '''This is triple quoted string using "single" quotes.''' You must create a new string inorder to incorporate the changes. Strings are immutable which means if you try to change any value in a string, it will throw an error. Triple_quote = """Triple quotes allows to embed "double quotes" as well as 'single quotes' in your string.Īnd can also span across multiple lines.""" single_quote = 'Single quote allow you to embed "double" quotes in your string.'ĭouble_quote = "Double quote allow you to embed 'single' quotes in your string." Triple quoted string let you work with multiple line strings, and all associated whitespace will be included in the string. Triple quotes, as in this example: """Triple quotes using double quotes""", '''Triple quotes using single quotes.'''.

For example: "Double quote allow you to embed 'single' quotes in your string." Single quotes, just like in this example: 'Single quote allow you to embed "double" quotes in your string.'.There can be multiple ways of doing this: To represent a string, you wrap it within quotes. Each number represents a unique character.

In unicode, each letter, character is represented as a 4-byte number. Unicode is a system designed to represent all characters from languages. Strings are immutable sequences of unicode. You can handle textual data in Python using the str object. This course dives deeper into functions, iterators, lists, etc. If you're interested to learn more about data structures in Python, surely check out DataCamp's two-part Python Data Science Toolbox.
