Answer to Question #198790 in Python for kolsuz

Question #198790

# Write a function good_string that consumes a string, produces True if the first character is a 

# letter and the second character is either a digit or a blank space and produces False 

# otherwise



1
Expert's answer
2021-05-26T06:55:32-0400
# A function that consumes a string and outputs True if the first
# character is a letter and the second is either a digit or a space
# and outputs False otherwise.


def good_string():
    user_input = str(input("Enter the string you need checked: \n"))

    answer = "False"

    if user_input[0].isalpha():
        if user_input[1].isnumeric() or user_input[1] == " ":
            answer = "True!"
        else:
            answer = "False!"
    else:
        answer = "False!"

    print(answer)

good_string()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS