Course Ten - String & variables in python

String & variables in python By ienex Strings are one of the most commonly used data types in Python. They are easily created by enclosing characters in single ( ' ) or double ( " ) quotes. var1 = 'Hello World!' var2 = "Python Programming" Accessing Values in Strings In Python, characters are treated as strings of length one , so a single character is considered a substring. You can access substrings using square brackets [] : var1 = 'Hello World!' var2 = "Python Programming" print("var1[0]:", var1[0]) print("var2[1:5]:", var2[1:5]) Output: var1[0]: H var2[1:5]: ytho Updating Strings Strings are immutable , so to update a string, you must assign a new value to the variable. You can also concatenate parts of the old string with a new string: var1 = 'Hello World!' print("Updated String:", var1[:6] + 'Python') Output: Updated String: Hello Python Escape Characters Escape c...