Overview Strings use single, double or triple quotes Triple quote strings span multiple lines Represent characters not numbers ("1 proton" vs 1 "proton"+ Strings can be concatenated ("1"+"1" becomes "11") Strings are Ordered Strings can be indexed Strings can be reverse indexed Strings are immutable Can not change a string (does not support item reassignment) Can be reassigned by slicing and concatenation Formatting Strings When you print a string there are a variety of format options. I personally tend to use the f-string, but you need to be prepared to read code that uses any of the options. Modulo (%) method .format() method f-string method String Methods String methods are functions that are built into the string object class. The following are some string methods See Python.org string section for a comprehensive list of string methods. Note, these should be quickly gone through and then used as references, and some of these involve classes like lists which are covered later in this section. str.capitalize() Lets analyze the code below. In the first line we assign the string "chemistry class" to a variable called name. Note the string is in parenthesis, but the name is not. Now we want to print the variable name but capitalize the first letter of the first word, and so we can use the capitalize method, which is a function of the class string, by typing .capitalize() after the string variable name. Note print is a function and so we place the argument (name) in it, and capitalize is a method (function of the class string), and so it also needs parenthesis, but it operates on the variable it is appended to. name = "chemistry class" print(name.capitalize()) If you wanted to capitalize the first letter of every word you would use the title method that is demonstrated below. str.find() note, this method finds the index number of the string, which is an ordered list. In python index numbers start with zero, and so the word "best" starts at the 17th index position of the string. text = 'Chemistry is the best course' print(text.find('best')) str.join (iterable) note the variable text is a list of strings and we cover lists in the next section. Here we are using the space string to join each of the words of the list into a stingle string. After you run the following, remove the blank spot in space, that is, convert " " to "" and then rerun the code. text = ['Chemistry', 'is', 'the', 'best', 'class'] space = " " print(space.join(text)) str.lstrip ([chars]) striping characters can be very important, especially if you import a file with a bunch of characters you do not want. Data transmitted over the web is usually a string and you often need to convert it to a number by removing the quotes. That is, 1 is an integer and "1" or '1' are strings. text = ",,,,,Hello world" x = text.lstrip(",") print(x) str.replace ("old", "new") text = 'Ozone Oxygen Butane' new_text = text.replace('Butane', 'Hydrogen') print(new_text) str.rsplit(separator, max split) Converts string into list of strings from the right, with the max split number indicating how many items in the list are created to the right. text = "Chemistry,Physics,Calculus" x = text.rsplit(",", 2) print(x) str.rstrip([chars]) text = "Pythonnnnnn" print(text.rstrip('n')) str.split(sep=None, maxsplit=-1) text = 'This programming langauge is cool' x = text.split(None,-1) print(x) x = text.split(None,1) print(x) x = text.split(None,2) print(x) str.title() text1 = 'python programming class' print(text1.title()) text2 = 'pyTHoN proGraMMinG clAsS'.title() print(text2.title())