@@ -81,14 +81,16 @@ So, here ya go...
81
81
- [ 💡 Explanation] ( #-explanation-10 )
82
82
- [ Midnight time doesn't exist?] ( #midnight-time-doesnt-exist )
83
83
- [ 💡 Explanation:] ( #-explanation-18 )
84
- - [ Counting the booleans] ( #counting-the -booleans )
84
+ - [ What's wrong with booleans? ] ( #whats-wrong-with -booleans )
85
85
- [ 💡 Explanation:] ( #-explanation-19 )
86
86
- [ Needle in a Haystack] ( #needle-in-a-haystack )
87
87
- [ 💡 Explanation:] ( #-explanation-20 )
88
- - [ Loop variable resilient to changes ] ( #loop-variable-resilient-to-changes )
88
+ - [ not knot! ] ( #not-knot )
89
89
- [ 💡 Explanation:] ( #-explanation-21 )
90
- - [ Let's see if you can guess this? ] ( #lets-see-if-you-can-guess-this )
90
+ - [ Loop variable resilient to changes ] ( #loop-variable-resilient-to-changes )
91
91
- [ 💡 Explanation:] ( #-explanation-22 )
92
+ - [ Let's see if you can guess this?] ( #lets-see-if-you-can-guess-this )
93
+ - [ 💡 Explanation:] ( #-explanation-23 )
92
94
- [ Minor Ones] ( #minor-ones )
93
95
- [ TODO: Hell of an example!] ( #todo-hell-of-an-example )
94
96
- [ Contributing] ( #contributing )
@@ -220,6 +222,7 @@ Shouldn't that be 100?
220
222
221
223
# ## Time for some hash brownies!
222
224
225
+ 1 \.
223
226
```py
224
227
some_dict = {}
225
228
some_dict[5.5 ] = " Ruby"
@@ -1379,8 +1382,9 @@ Before Python 3.5, the boolean value for `datetime.time` object was considered t
1379
1382
1380
1383
-- -
1381
1384
1382
- # ## Counting the booleans
1385
+ # ## What's wrong with booleans?
1383
1386
1387
+ 1 \.
1384
1388
```py
1385
1389
# A simple example to count the number of boolean and
1386
1390
# integers in an iterable of mixed data types.
@@ -1403,6 +1407,21 @@ for item in mixed_list:
1403
1407
4
1404
1408
```
1405
1409
1410
+ 2 \.
1411
+ ```py
1412
+ another_dict = {}
1413
+ another_dict[True ] = " JavaScript"
1414
+ another_dict[1 ] = " Ruby"
1415
+ another_dict[1.0 ] = " Python"
1416
+ ```
1417
+
1418
+ ** Output:**
1419
+ ```py
1420
+ >> > another_dict[True ]
1421
+ " Python"
1422
+ ```
1423
+
1424
+
1406
1425
# ### 💡 Explanation:
1407
1426
1408
1427
* Booleans are a subclass of `int `
@@ -1413,6 +1432,12 @@ for item in mixed_list:
1413
1432
True
1414
1433
```
1415
1434
1435
+ * The integer value of `True ` is `1 ` and that of `False ` is `0 ` .
1436
+ ```py
1437
+ >> > True == 1 == 1.0 and False == 0 == 0.0
1438
+ True
1439
+ ```
1440
+
1416
1441
* See this StackOverflow [answer](https:// stackoverflow.com/ a/ 8169049 / 4354153 ) for rationale behind it.
1417
1442
1418
1443
-- -
0 commit comments