devops-exercises/exercises/python/solutions/reverse_string.md

17 lines
236 B
Markdown
Raw Normal View History

2021-08-13 08:23:50 +02:00
## Reverse a String - Solution
```
my_string[::-1]
```
A more visual way is:<br>
<i>Careful: this is very slow</i>
```
def reverse_string(string):
temp = ""
for char in string:
temp = char + temp
return temp
```