Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Tuesday, November 17, 2020

Python program to input a character and to print whether a given character is an alphabet, digit or any other character by G Krishna Chauhan

Source Code


ch=input("Enter a character: ") 

    if ch.isalpha(): 

        print(ch, "is an alphabet") 

    elif ch.isdigit(): 

        print(ch, "is a digit") 

    elif ch.isalnum(): 

        print(ch, "is alphabet and numeric") 

    else:

        print(ch, "is a special symbol")



OUTPUT


 Enter a characterA

A is an alphabet


Enter a character$

$ is a special symbol


Enter a characterGK2

GK2 is alphabet and numeric


Enter a character9

9 is a digit

No comments:

Post a Comment