In: Computer Science
Please provide Python code that does the following:
3) Write a program that takes a string as input, checks to see if it is comprised entirely of letters, and if all those letters are lower case. The output should be one of three possible messages:
Your string is comprised entirely of lower case letters.
Your string is comprised entirely of letters but some or all are upper case.
Your string is not comprised entirely of letters.
Your program may NOT:
Program:
#Importing re for using regex
import re
#main() definition
def main():
#user input
str=input("Enter a string: ")
#checking for digits and special characters in the string
if re.search("[^a-zA-z]",str):
print("Your string is not comprised entirely of letters.")
else:
#checking for UPPERCASE letters
if re.search("[A-Z]",str):
print("Your string is comprised entirely of letters but some or all
are upper case.")
else:
print("Your string is comprised entirely of lower case
letters.")
#function call
main()
Sample Runs:
For Indentation Reference: