# Noemi Cabrera # 8 October 2021 # In this project, I created a program that gets input and analyses it. I applied various methods I had learned # in the past modules and the new one to create a program that can check if the input is a word or integer. # If it's not, then the user will be asked to enter a valid word or integer until the input is valid and not empty. # I didn't have any difficulties creating this program.
# [ This program asks te user to enter an integer or word. If the input is a word, a message indicating is a word is displayed # and the loop breaks. If the input is an integer, a message indicating is an integer is displayed and the loop breaks. # But if the input is not word, an integer, or is empty, a message indicating that is displayed and the loop runs until # a valid word or integer is entered.] create, call and test the str_analysis() function def str_analysis(string): while True: string = input("Enter a word or integer: ") if string.isdigit(): if int(string) > 99: return print(string +" is a pretty big number") break else: return print(string +" is a smaller number than expected") break elif string.isalpha(): return print(string + " is all alphabetical characters!") break else: print(string, "This is not a number or alphabetical character.\n Try Again") str_analysis("34")
45 is a smaller number than expected