Looking to get a head start on your next software interview? Pickup a copy of the best book to prepare: Cracking The Coding Interview!
toUpperCase() method to convert a string to uppercase. But what if you’re working in Python? Fortunately, Python has a built-in method for converting strings to uppercase as well.
The method for converting a string to uppercase in Python is
upper(). This method returns a new string with all the characters in uppercase.
Here’s an example:
string = "hello world"
uppercase_string = string.upper()
This code will output:
As you can see, the
upper() method converted all the characters in the string to uppercase.