The rstrip() method is used in this code to remove whitespace(including Spaces, tabs, newlines, and so on) at the end of the string. Note, however, that this method can only remove whitespace characters at the end of the string, not Spaces in the middle of the string.
In this example, the language variable is the string "'Python '" containing single quotes and Spaces. Since the space is at the end of the string, calling the rstrip() method removes it, but since single quotes are not Spaces, they are not removed. To remove whitespace and single quotes at both ends of a string, use the strip() method: favorite_language.strip("'").strip().