Skip to content

Commit 64ad512

Browse files
committed
new tip
1 parent 350d190 commit 64ad512

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This file gets generated by [this script](index.py).
2323
- [Any / all built-ins](notes/20220906181721.md)
2424
- [Char to number](notes/20221216114150.md)
2525
- [Dict() type constructor](notes/20221124082215.md)
26+
- [Divmod built-in](notes/20251013163518.md)
2627
- [Get a loop counter with enumerate()](notes/20220905182723.md)
2728
- [Getattr for safely access attributes](notes/20240206102145.md)
2829
- [Look for multiple indices in a list](notes/20221201102028.md)

notes/20251013163518.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# divmod built-in
2+
3+
Ever needed both integer division (`//`) and remainder (`%`)? 🤔
4+
5+
Instead of running two operations, use hashtag#Python’s `divmod()` built-in -> it returns both in one go ⚡️
6+
7+
```python
8+
>>> total_seconds = 133
9+
>>> minutes, seconds = divmod(total_seconds, 60)
10+
>>> minutes
11+
2
12+
>>> seconds
13+
13
14+
```
15+
16+
#built-ins

0 commit comments

Comments
 (0)