Post

Khalid | Python Tasks Adventurer 🐍
🐍 Python tip Need to check if all items are equal? Instead of: len(set(items)) == 1 try the cleaner way with more-itertools ✨ from more_itertools import all_equal print(all_equal([1, 1, 1])) # True print(all_equal("aaaa")) # True print(all_equal("abca")) # False 💡 Why all_equal()? ✅ more expressive ✅ works with iterators ✅ supports unhashable items too Even this works 👇 print(all_equal([])) # True #Python #PythonCode #Coding #Programming #100DaysOfCode
English
0
0
0
34
Paylaş