Python reference
Look up Python syntax and everyday functions one topic at a time. To learn from the start in order, go to Learn Python.
- Python break vs continuebreak ends the loop; continue skips only the current iteration
- Python Dictionary (dict): Keys and ValuesLook up and change values by key, handle missing keys, loop, count
- Python enumerate(): Loop with Index and ValueGet the index and the value together as you loop
- Python f-string: Format Numbers and TextPut values inside a string: decimal places, width, alignment
- Python for LoopLoop over the values in a list or string one at a time
- Python input(): Read User InputRead one line of keyboard input, convert it to a number, read several lines
- Python join(): Join a List into a StringJoin a list of strings into one string with a separator
- Python List append(), extend() and insert()Add values to a list with append, extend and insert
- Python: Remove Duplicates from a ListDrop duplicates with set, or keep the original order with dict.fromkeys
- Python sort() vs sorted(): Sort a ListThe difference between sort and sorted, and choosing the order with key and reverse
- Python print(): Output with sep and endPrint values to the screen: several values, sep, end
- Python range(): Start, Stop and StepFrom 0 to n-1, start, stop and step, counting backwards
- Python Slicing: [start:stop:step] ExplainedCut a piece out of a string or list with [start:stop:step]
- Python split(): Split a String into a ListCut a string at a separator and get a list
- Python while LoopRepeat while a condition is true, while True and an end marker