Quick actions

cmd+k|ctrl+k

Navigation

Languages

reverseString_V1

Snippet info

Language

Python

Visibility

public

Author

cyfung818

Created

2024-08-06T03:54:19.953473Z

Updated

2024-08-06T03:54:19.953473Z

# - **Question**: Write a function that takes a string and returns the string reversed.
# Include error handling to manage cases where the input is not a string.
# - **Example**: Input: `"hello"`, Output: `"olleh"`.

# input = string
# output = string
# error handling

def reverseString(input_string):
    return input_string[::-1]

string_example1 = "hello"
string_example2 = "Sauron"
string_example3 = "12345"

print(reverseString(string_example1))
print(reverseString(string_example2))
print(reverseString(string_example3))
INFO