Home » Python

Python String | isupper() and islower() Methods with Examples

Python String | isupper() and islower() Methods with Examples, these are the in-built methods in Python, which are used to check whether a string is in Uppercase or Lowercase.
Submitted by IncludeHelp, on July 18, 2018

isupper() and islower() both are the in- built methods in Python which works with the strings.

1) String isupper() Method

isupper() returns "true" if all characters of the string are uppercase character.

Syntax:

 String.isupper()

Parameter: None

Return type:

  • true - if all characters of the string are uppercase characters.
  • false - if any of the characters is not in uppercase character.

Example:

# str1 with all uppercase characters
str1 = "GOOGLE"
print str1.isupper()

# str2 with uppercase character, DOT, SPACE 
str2 = "GOOGLE.COM"
print str2.isupper()

# str3 with uppercase and lowercase characters
str3 ="GOOGLE.com"
print str3.isupper()

# str4 with all lowercase characters
str4 = "google.com"
print str4.isupper()

Output

    True
    True
    False
    False

2) String islower() Method

islower() returns "true" if all characters of the string are lowercase character.

Syntax:

 String.islower()

Parameter: None

Return type:

  • true - if all characters of the string are lowercase characters.
  • false - if any of the characters is not in lowercase character.

Example:

# str1 with all lowercase characters
str1 = "google"
print str1.islower()

# str2 with lowercase character, DOT, SPACE 
str2 = "google.com"
print str2.islower()

# str3 with lowercase and uppercase characters
str3 ="google.COM"
print str3.islower()

# str4 with all uppercase characters
str4 = "GOOGLE.COM"
print str4.islower()

Output

    True
    True
    False
    False





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.