Write a Python function named "reverse_string" that takes a string as input and returns the reverse of the input string.
时间: 2024-03-10 14:45:17 浏览: 90
Python序列对象与String类型内置方法详解
Sure! Here's a Python function named "reverse_string" that takes a string as input and returns the reverse of the input string:
```python
def reverse_string(input_str):
return input_str[::-1]
```
Here, we're using Python's string slicing notation to reverse the input string. The `[::-1]` slice means to take the entire string, but step backwards by 1 character at a time. This effectively reverses the order of the string.
阅读全文