Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Write a function to reverse a string.
Answer:

def reverse_string(input_str):

return input_str[::-1]

Example:

reverse_string('hello')  # Output: 'olleh'
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook