File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments