# File: strtype.py # Returns the number of types of characters in a string # # Matt Bishop, ECS 10, Fall 2012 # # instr = input("Enter a string: ") # put quotes around the string to show its boundaries when it is printed prstr = '"' + instr + '"' # # now test the character types # if instr.isalpha(): print(prstr, "contains only letters") if instr.isalnum(): print(prstr, "contains only alphanumeric characters") if instr.isdigit(): print(prstr, "contains only digits") if instr.isspace(): print(prstr, "contains only white space") if instr.isupper(): print(prstr, "contains only upper case letters") if instr.islower(): print(prstr, "contains only lower case letters")