Python String Method

Python String isalnum() Method

  • Python string isalnum() function returns True if it’s made of alphanumeric characters only. A character is alphanumeric if it’s either an alpha or a number.

  • If the string is empty, then isalnum() returns False.

Syntax

                                       string_name.isalnum() 

Parameter 

  • isalnum() method takes no parameters 

Return Value

  • True: If all the characters are alphanumeric.

  • False: If one or more characters are not alphanumeric.

Python String isspace() Method

  • The isspace() method returns True if there are only whitespace characters in the string. If not, it return False. 

Syntax 

                                     string.isspace()

Parameters

  • The isspace() method doesn't take any parameters. 

Return Value

  • True- If all characters in the string are whitespace characters.

  • False- If the string contains 1 or more non-whitespace characters.

Python String islower() Method

  • The islower() methods returns “True” if all characters in the string are lowercase, Otherwise, It returns “False”.

  • This function is used to check if the argument contains any lowercase characters such as : abcdefghijklmnopqrstuvwxyz

Syntax :

string.islower()

Parameters:

  • islower() does not take any parameters  

Returns :

  • True- If all characters in the string are lower. 

  • False- If the string contains 1 or more non-lowercase characters. 


Python String isupper() Method

  • The isupper() methods returns “True” if all characters in the string are uppercase, Otherwise, It returns “False”.

  • This function is used to check if the argument contains any uppercase characters such as : ABCDEFGHIJKLMNOPQRSTUVWXYZ

Syntax :

string.isupper()

Parameters: 

  • isupper() does not take any parameters  

Returns :

  • True- If all characters in the string are uppercase. 

  • False- If the string contains 1 or more non-uppercase characters.

 

  

 



 

 

 

Comments