added new snippet reverse_string
This commit is contained in:
18
snippets/reverse_string.md
Normal file
18
snippets/reverse_string.md
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
title: reverse_string
|
||||
|
||||
tags: string,beginner
|
||||
---
|
||||
|
||||
Returns the string after reversing it.
|
||||
|
||||
Use string slicing to rotate the string.
|
||||
|
||||
```py
|
||||
def reverse_string(string):
|
||||
return string[::-1]
|
||||
```
|
||||
|
||||
```py
|
||||
reverse_string("snippet") #"teppins"
|
||||
```
|
||||
Reference in New Issue
Block a user