Convert a string to uppercase in Python
Hello friends, in this tutorial I will tell you how to convert a string variable’s case to its uppercase equivalent in Python.
Convert a string to uppercase in Python
This method is used to convert any string’ value to its equivalent uppercase value. In this example, I have taken a sample string and stored it in temporary variable, sample_Str
. Then, I have used the upper()
function and attributed the sample_Str
along with it. Thus, I get an output where all the characters of the sample_Str present are converted to their uppercase equivalents.
Code :
sample_Str = 'HELLO THIS is CodeSpeedy' new_Str = sample_Str.upper() print(new_Str)
Output :
HELLO THIS IS CODESPEEDY
Thus you can now successfully convert a string to uppercase.
Leave a Reply