Tagged: Python
4 articles tagged Python across all clusters on CodeWalkers.
List and Dict Comprehensions in Python
A comprehension builds a list or a dictionary from an existing iterable in one expression. The syntax for both forms, filtering, conditional values, nesting, and the cases where a plain loop is the better answer.
Lists vs Dictionaries vs Sets in Python
Three built-in collections answer three different questions: what came in what order, what is stored under this name, and have I seen this before. A criteria-based way to pick one, with the cost of picking wrong.
Python Dictionaries: Keys, Values, Updates, Loops, and JSON
A Python dictionary stores values under names you choose instead of numbered positions. Creating one, reading keys safely, updating and merging, looping over views, counting and grouping, and the JSON boundary.
Python Lists: Create, Slice, and Iterate
A Python list keeps items in the order you put them and lets you change that order later. How to create one, index and slice it, add and remove items, copy it safely, and recognise the jobs a list is wrong for.