Write a Python function named "reverse_string" that takes a string as input and returns the reverse of the input string.ues python
时间: 2024-03-10 08:45:40 浏览: 113
Takes a string and reverses it.
Sure, here is the code for the "reverse_string" function in Python:
```python
def reverse_string(input_string):
return input_string[::-1]
```
This function takes a string "input_string" as input and uses slicing with a step of -1 to reverse the string. The syntax `[::-1]` means to start at the end of the string and move backwards one character at a time until the beginning of the string is reached. The reversed string is then returned by the function.
阅读全文