Python Uppercase in String

Hey learner, In this topic you can learn python uppercase in string. In python programming the upper() method is use to convert the lowercase character into uppercase character. After learning this tutorial you have knowledge about upper() method, lower() method and capitalize() method.

python uppercase in string

In python string the upper() method is used to convert all the letter into uppercase. The syntax of python uppercase is:

Syntax      :         string.upper()
  • Parameters: In upper() method doesn’t take any parameter.
  • Return Value: In upper() method return the string value, which is converted all the lowercase string into the uppercase string.

Example For Python Uppercase In String

Example 1

python uppercase example 1

Code

#string with upper case
string = 'The age of Alina is 30 year'

#convert into Uppercase
string.upper()
Output : THE AGE OF ALINA IS 30 YEAR

In the above python uppercase program, the string is taken, In which the character are in lowercase and uppercase, So by using string.upper() method, all the character can be converted into uppercase.


Example 2

python uppercase example 2

Code

#string
string = 'Technoelearn'

#convert into Uppercase
string.upper()
Output : TECHNOELEARN

As you can see in the above python uppercase program, the string variable contains a word which is in lowercase and first letter is in uppercase. So by using string.upper() method all the lowercase character are converted into the uppercase as you can see in the output.

isupper() Method:

To check the string are in uppercase, use isupper() method to chek all the string are in uppercase or not. The isupper() method return true or false. If the given string are in uppercase then isupper() method return true and if some letter are in lowercase the it return false. And also to check the string is in lowercase islower() method is used. The syntax of islower() method is:

Syntax :  string.isupper()

Example with some uppercase and some lowercase character.

Python isupper 1

Code

#take a string
string = 'Technoelearn'

#check the string are in uppercase!
string.isupper()
Output : False

In the above isupper() method, the string variable contains string ‘Technoelearn’. Some character are in uppercase and some are in lowercase. So, by using isupper method the method to check the string are in upper case. The isupper() method return the False because the except first letter all the letter are in lowercase.

Example with uppercase string

python isupper 2

Code

#take a string
string = 'TECHNOELEARN'

#check the string are in lowercase!
string.isupper()
Output : True

In the above python program, The isupper() method is used to check all the letter are in uppercase or not. As you can see in the output, The method returns the True Value because the string contains all the uppercase letter.


Video Tutorial For Python Uppercase In String

FAQ For Python Uppercase In String

How to make a string uppercase in python?

In python programming the upper() method is used to make a string in uppercase. By using upper() method all the string are converted into uppercase. The syntax of upper() method is:
string.upper()

How upper method is used in python programming?

The upper() method is used in python programming for converting all the string into uppercase. The syntax of upper() method is : string.upper()

What is python isupper method?

In python, isupper() method is used to check the given string are in the uppercase or in lowercase. If the string is in uppercase then return true value otherwise return false.


Learn More Python Programming Language

If you have any queries regarding python uppercase string then ask on the comment section, I am happy to answer your question

1 thought on “Python Uppercase in String”

Leave a Comment

Share via
Copy link
Powered by Social Snap