python logo

upper python


Python hosting: Host, run, and code Python in the cloud!

Transforming a string to uppercase in Python is a frequently used functionality. Python offers a straightforward method for this task: str.upper(). Here’s how to use it.

Syntax

The syntax to convert a string to uppercase in Python is:

str.upper()

This method doesn’t require any parameters and will return the original string in uppercase form.

Parameters

There are no parameters required for the str.upper() method.

Example

Let’s see the str.upper() method in action:

s = "All work and no play makes Jack a dull boy. Jack?"
s = s.upper()
print(s)

Executing the above code will produce the following result:

ALL WORK AND NO PLAY MAKES JACK A DULL BOY. JACK?

The original string has been transformed to its uppercase version.

BackNext





Leave a Reply: