M.Sc Python Programming Assignment 29
M.Sc Python Programming Assignments Assignment 29 Question: Write a Python class to reverse a string word by word. Input string : ‘hello.py’ Expected Output : ‘.py hello’ Code: class StringReverser: def reverse_words(self, input_string): words = input_string.split() reversed_string = ‘ ‘.join(reversed(words)) return reversed_string # Example usage input_string = input(“Enter a string: “) reverser = StringReverser() reversed_string …