diff --git a/README.md b/README.md index b48ed3b..d43cb55 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ sorted_by_second = sorted(, key=lambda el: el[1]) flattened_list = [item for sublist in for item in sublist] ``` +```python +>>> list('ABC') +['A', 'B', 'C'] +``` + Dictionary ---------- ```python @@ -156,11 +161,11 @@ String ------ ```python str.replace(text, old, new) -.isnumeric() .split(sep=None, maxsplit=-1) .strip() .join() .startswith() +.isnumeric() ``` ### Print @@ -199,7 +204,7 @@ re.split(, text, maxsplit=0) # Use brackets in regex to keep the matches {:min_width} # ' ' {:>min_width} # ' ' {:^min_width} # ' ' -{:_min_width} # '____' +{:_____' {:.max_width} # '' ``` ```python @@ -219,6 +224,19 @@ re.split(, text, maxsplit=0) # Use brackets in regex to keep the matches '187' ``` +```python +>>> f'{123:020b}' +'00000000000001111011' +``` + +#### Integer presentation types: +* 'b' - binary +* 'c' - character +* 'o' - octal +* 'x' - hex +* 'X' - HEX + + ### Text Wrap ```python import textwrap @@ -239,7 +257,7 @@ random.choice() Infinity -------- ```python -float("inf") +float('inf') ``` Datetime @@ -512,9 +530,11 @@ Exceptions while True: try: x = int(input("Please enter a number: ")) - break except ValueError: print("Oops! That was no valid number. Try again...") + else: + print("Thank you.") + break ``` Threading