Mastering String Manipulation in Python: An Introduction to Strings and String Slicing
Strings Strings in python are defined by enclosing with either single quotation marks (") or double quotation marks (") 1 2 str_hello = "Hello..." str_hello = 'Hello...' It does not make a difference in the way string is stored and/or used in the program based on the way it is declared (i.e., by using single quotation marks or double quotation marks). Multi-line strings Above declaration is applicable when the string is of a single line. If we have a string that has multiple lines, multi-line string can be defined by enclosing with either three single quotation marks (''') and double quotation marks ("""). 1 2 3 4 5 6 7 multi_string = """Hello World, This is a multi-line string. enclosed in double quotation marks""" multi_string = '''Hello World, This is a multi-line string. enclosed in single quotation marks''' Accessing part of the string by using index String is similar to...