How would you convert a string into uppercase?
Use the upper() method. It returns a new string with all letters in capital. Like all string methods, it does not change the original string.
name = "david smith"
print(name.upper())
print(name.title())
print(name.capitalize())
Output:
Tutorials Class - Output Window
DAVID SMITH
David Smith
David smith
title() makes the first letter of every word a capital, and capitalize() changes only the first letter of the whole string. The opposite of upper() is lower(), explained in this question.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |