Python String islower() Method (original) (raw)
Last Updated : 11 Nov, 2024
The **islower() method in Python checks if all characters in a string are lowercase. It returns **True if all alphabetic characters are lowercase, otherwise, it returns **False, if there is at least one uppercase letter.
Let’s look at a quick example of using the islower() method.
Python `
s = "hello" res = s.islower() print(res)
`
**Explanation: The string **s contains only lowercase alphabetic characters, so **islower() returns **True.
Table of Content
Syntax of islower()
s.islower()
Parameter:
- This method doesn’t take any parameter.
Return Value:
- The method return **True if all alphabetic characters in the string are lowercase, otherwise **False.
Example of islower()
Let’s look at a few examples of islower() method.
Python `
s1 = "hello" res1 = s1.islower() print(res1)
s2 = "Hello" res2 = s2.islower() print(res2)
s3 = "hello123" res3 = s3.islower() print(res3)
s4 = "" res4 = s4.islower() print(res4)
s5 = "123@" res5 = s5.islower() print(res5)
`
Output
True False True False False
**Explanation:
- **s1 is **“hello”: contains only lowercase letters, so islower() returns **True.
- **s2 is **“Hello”: has an uppercase ‘H’, so islower() returns **False.
- **s3 is **“hello123”: all alphabetic characters are lowercase, so islower() returns **True.
- **s4 is **“”: an empty string returns **False by default.
- **s5 is **“123@”: contains no alphabetic characters, so islower() returns **False. At least one lowercase letter is needed for **True.
**Related Articles:
- Python String isupper() Method
- Python String isalpha() Method
- Python String isdigit() Method
- Python String isalnum() Method
Similar Reads
- Python String count() Method The count() method in Python returns the number of times a specified substring appears in a string. It is commonly used in string analysis to quickly check how often certain characters or words appear. Let's start with a simple example of using count(). [GFGTABS] Python s = "hello world" r 2 min read
- Python - Strings encode() method String encode() method in Python is used to convert a string into bytes using a specified encoding format. This method is beneficial when working with data that needs to be stored or transmitted in a specific encoding format, such as UTF-8, ASCII, or others. Let's start with a simple example to unde 3 min read
- Python String endswith() Method The endswith() method is a tool in Python for checking if a string ends with a particular substring. It can handle simple checks, multiple possible endings and specific ranges within the string. This method helps us make our code cleaner and more efficient, whether we're checking for file extensions 3 min read
- expandtabs() method in Python expandtabs() method in Python is used to replace all tab characters (\t) in a string with spaces. This method allows for customizable spacing, as we can specify the number of spaces for each tab. It is especially useful when formatting text for better readability or alignment. Let's understand with 3 min read
- Python String find() Method find() method in Python returns the index of the first occurrence of a substring within a given string. If the substring is not found, it returns -1. This method is case-sensitive, which means "abc" is treated differently from "ABC". Example: [GFGTABS] Python s = "Welcome to GeekforGeeks!" 2 min read
- Python String format() Method format() method in Python is a tool used to create formatted strings. By embedding variables or values into placeholders within a template string, we can construct dynamic, well-organized output. It replaces the outdated % formatting method, making string interpolation more readable and efficient. E 9 min read
- Python String format_map() Method Python String format_map() method is an inbuilt function in Python, which is used to return a dictionary key's value. Syntax: string.format_map(z) Parameters: Here z is a variable in which the input dictionary is stored and string is the key of the input dictionary. input_dict: Takes a single parame 2 min read
- Python String index() Method The index() method in Python is used to find the position of a specified substring within a given string. It is similar to the find() method but raises a ValueError if the substring is not found, while find() returns -1. This can be helpful when we want to ensure that the substring exists in the str 2 min read
- Python String isalnum() Method The isalnum() method is a string function in Python that checks if all characters in the given string are alphanumeric. If every character is either a letter or a number, isalnum() returns True. Otherwise, it returns False. For Example: [GFGTABS] Python s = "Python123" res = s.isalnum() pr 2 min read
- Python String isalpha() Method The isalpha() method checks if all characters in a given string are alphabetic. It returns True if every character in the string is a letter and False if the string contains any numbers, spaces, or special characters. Let’s start with a simple example of using isalpha() [GFGTABS] Python s1 = "H 2 min read