Update some snippets

This commit is contained in:
Angelos Chalaris
2019-08-20 10:38:09 +03:00
parent 1c93753ade
commit f10d3f018b
6 changed files with 37 additions and 47 deletions

View File

@ -1,14 +1,16 @@
---
title: decapitalize
tags: string
tags: string,intermediate
---
Decapitalizes the first letter of a string.
Decapitalizes the first letter of the string and then adds it with rest of the string. Omit the `upper_rest` parameter to keep the rest of the string intact, or set it to `true` to convert to uppercase.
Decapitalize the first letter of the string and then add it with rest of the string.
Omit the `upper_rest` parameter to keep the rest of the string intact, or set it to `True` to convert to uppercase.
```py
def decapitalize(string, upper_rest=False):
return str[:1].lower() + (str[1:].upper() if upper_rest else str[1:])
return str[:1].lower() + (str[1:].upper() if upper_rest else str[1:])
```
```py