WORD COMBINER

IFRAME SYNC def word_combiner(word1, word2): combined_word = word1 + word2 return combined_word # Example usage if __name__ == "__main__": word1 = input("Enter the first word: ") word2 = input("Enter the second word: ") result = word_combiner(word1, word2) print("Combined word:", result)def word_combiner(word1, word2, method='concatenate'): if method == 'concatenate': combined_word = word1 + word2 elif method == 'merge': combined_word = ''.join([a + b for a, b in zip(word1, word2)]) else: raise ValueError("Invalid combination method. Supported methods: 'concatenate', 'merge'") return combined_word def main(): while True: word1 = input("Enter the first word (or 'exit' to quit): ") if word1.lower() == 'exit': break word2 = input("Enter the second word: ") combination_method = input("Choose combination method ('concatenate' or 'merge'): ").lower() try: result = word_combiner(word1, word2, method=combination_method) print("Combined word:", result) except ValueError as e: print(f"Error: {e}") if __name__ == "__main__": main() IFRAME SYNC

Comments