Google News
logo
Python Program to Convert a string to upper case
In the following example of Python program that demonstrates how to convert a string to upper case using the built-in upper() function :
Program :
# Convert a string to upper case
my_string = "Hello, World!"
uppercase_string = my_string.upper()

print("The upper case string is:", uppercase_string)
Output :
The upper case string is: HELLO, WORLD!
In the above program, we start by assigning the string value `"Hello, World!"` to the variable `my_string`. We then use the `upper()` function to convert `my_string` to upper case, and assign the result to the variable `uppercase_string`.

Finally, we use the `print()` function to print the message "The upper case string is:" followed by the value of `uppercase_string`.

As you can see, the `upper()` function converts all of the characters in the string to upper case.