Conversion and Comparison
Explore methods for converting strings to different cases and numeric types in Python. Understand how to compare strings lexicographically and work with byte sequences for binary data representation.
We'll cover the following...
We'll cover the following...
String conversions
Two types of string conversions are frequently required:
- Converting the case of characters in a string.
- Converting numbers to a string and vice versa.
Case conversions
Case conversions can be done using the following str methods:
upper(): Converts string to uppercase.lower(): Converts string to lowercase.capitalize(): Converts the first character of a string to uppercase.title(): Converts the first character of each word to uppercase.swapcase(): Swaps cases in the string.