Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
string
upper
communitycreator

What is string.upper() in Python?

Programming Bytes

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

The upper method in Python converts all the characters of a string to uppercase.

Syntax

string_A.upper()

Parameter

The function takes in no parameters.

Return value

The function returns a new string that is created from string_A by converting all the characters of string_A to uppercase.

If there are no lowercase characters in string_A, then the original string is returned.

All the characters of the string are converted to uppercase

Code

string_A = "eduCativE"
print(string_A, " upper() -> ", string_A.upper())

In the code above, we create an eduCativE string and call the upper method, which converts all of the characters of the string to uppercase and returns EDUCATIVE.

string_A = "Educative"
string_B = "EDUCATIVE"
print("String_A = ", string_A)
print("String_B = ", string_B)
print("String_A == String_B ", string_A == string_B)
print("String_A.upper() == String_B.upper() ", string_A.upper() == string_B.upper())

In the code above, we create two strings, Educative and EDUCATTIVE. We get False when we compare the two strings because the cases of the strings are different.

We then use the upper method to convert both strings to uppercase. After both strings are converted to uppercase, we get True when we check whether the two strings are the same.

RELATED TAGS

python
string
upper
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring