Tuesday, November 5, 2019

isalnum,isalpha,islower,isspace methods in python


"""
Created on Sun Nov  3 09:54:15 2019

@author: anil durgam
"""

s=input("Enter any character:")
if s.isalnum():
    print("Alpha numeric character")
    if s.isalpha():
        print("Alphabet character")
        if s.islower():
            print("Lower case alphabet character")
        else:
            print("Upper case alphabet character")
    else:
        print("It is a digit")
elif s.isspace():
    print("It is space character")
else:
    print("Non space Special character")


output:

Enter any character:5
Alpha numeric character
It is a digit



Enter any character:a
Alpha numeric character
Alphabet character
Lower case alphabet character


Enter any character:
It is space character
    

No comments:

Post a Comment

python class topic video