Write a lambda function that takes a string and returns the reversed string.
Example 1:
Input: 'hello'
Output: 'olleh'
Example 2:
Input: 'world'
Output: 'dlrow'
Use a lambda function and string slicing.
# Define the lambda function
reverse_str = lambda s: s[::-1]
# Test the function
print(reverse_str('hello')) # Output: 'olleh'
print(reverse_str('world')) # Output: 'dlrow'
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.