Example
For Loop Basics
…iterates through sequence elements. Basic iteration over lists.
Showing 41–50 of 92
Example
…iterates through sequence elements. Basic iteration over lists.
Challenge
…number of numbers, call it with loose values and with a list unpacked by *, then add a keyword-only decimals option after *values and return None when there are no values.
Challenge
…find out where range() stops, fix it with ORBITS + 1, then list every third orbit with a range() step.
Challenge
Send a command up to three times, taking each result from a list of simulated radio replies, and stop at the first success with break; then wait 2, 4, 8 seconds between attempts, as real retry code…
Challenge
…is found with one lookup instead of a search through the list, then answer a list of requests, including an ID that isn't on the manifest.
Challenge
…with strip() and lower(), check it against the command list, then accept underscores and dashes too, so commands match however operators type them.
Challenge
Every morning, mission control wants one short list: which launches are coming up, in what order, and how long until each. The launch archive's API has all of it, as JSON, in no particular order and…
Challenge
…collections.Counter, which starts every key at 0, then list the levels from most to least common with most_common().
Article Python Fundamentals
…") # Empty surface print() # New line after each row # List of found rovers print("\n=== FOUND ROVERS REPORT ===\n") for scan_y in range(10): for scan_x in range(10): for x, y, name in lost_rovers: if…
Article Python Fundamentals
…= True engines_active = False Complex Data Types Lists Ordered collections of items, great for storing sequences of data: planet_names = ["Mercury", "Venus", "Earth", "Mars"] temperatures = [167, 464…