import string def is_valid_name(name): """Check if the name contains only alphabetic characters.""" return name.isalpha() def get_valid_input(prompt): """Prompt the user for input until a valid name is provided.""" while True: name = input(prompt) if is_valid_name(name): return name print("Invalid input. Please enter a name with letters only.") def calculate_name_length(name): """Calculate the length of a name.""" return len(name) def calculate_love_score(length1, length2): """Calculate the love match score based on name lengths.""" return (length1 * length2) % 11 def get_love_bar(score): """Generate a visual representation of the love score.""" return '#' * score def get_love_message(score): """Retrieve the corresponding love message based on the score.""" messages = [ "You are a bad", "You are still bad", "You need drugs to make it work", "noice" ] index = min(score // 3, len(messages) - 1) return messages[index] def print_output(score, love_bar, message): """Format and print the final output.""" print(f"Your Love Match score is: {score}") print(f"Love Match bar: [{love_bar}]") print(message) def main(): print("Welcome to the Love Match Calculator!") # Get names from the user name1 = get_valid_input("First person's name: ") name2 = get_valid_input("Second person's name: ") # Calculate lengths length1 = calculate_name_length(name1) length2 = calculate_name_length(name2) # Calculate love match score love_score = calculate_love_score(length1, length2) # Generate love bar love_bar = get_love_bar(love_score) # Get love message love_message = get_love_message(love_score) # Print the output print_output(love_score, love_bar, love_message) if __name__ == "__main__": main()