How do you convert a string to uppercase in Python?

To convert a string to uppercase in Python, you can use the upper() method. This method is available for strings and returns a new string where all the characters are in uppercase. Here's an example:

my_string = "hello world" uppercase_string = my_string.upper() print(uppercase_string) 



In the example above, the upper() method is called on the my_string variable, which contains the string "hello world". The resulting uppercase string is stored in the uppercase_string variable, and then it is printed to the console. To know more about Python then you should choose the right place for learning, I recommended Best Python Training in Meerut for better learning.

Python 30-06-23, 2:58 p.m. Muskan

Log-in to answer to this question.