Results for “new line”

Showing 31–40 of 44

  1. Challenge

    Counter

    …works: a dict, and counts.get(level, 0) + 1 to start each new level at 0. That pattern comes up so often that Python has a whole class for it. Swap it in, then use the one thing a plain dict can't do…

    Fix the code Easy 2 stages collections Counter most_common dictionaries
  2. Challenge

    Running totals

    …keeps one variable up to date instead of creating a new one for each step. Predict how -= and += change a value, follow the fuel through a whole sequence, then track a battery yourself. Predict and…

    Write the code Easy 3 stages variables -= += updating values
  3. Article Python Fundamentals

    Nested Loops in Python

    …X: 3 Scanning position X: 4 The problem is that's just one line. Mars surface has two dimensions - latitude and longitude. In this case, x_position shows us step by step which square we're scanning…

  4. Challenge

    Magic numbers

    …yet. Read it and decide what it will print on its first line. Write your guess in prediction , at the top, between the quotes. Then run it and compare. Any guess passes this stage: the point is to…

    Fix the code Easy 3 stages constants refactoring variables clean code
  5. Article Python Fundamentals

    Python Functions for Beginners

    If you've written even a few lines of Python, you've already used functions. print() is one. So are len() , input() and int() . Somebody wrote them, gave each one a name, and now you can use them…

  6. Challenge

    Lookup table

    …in a chain of nine elif branches, one per body, and every new destination means another branch. Turn the chain into a table without changing a single character of the output, then use the table for…

    Fix the code Medium 2 stages dictionaries refactoring lookup tables get
  7. Article Mini projects

    Base 6 Number System in Python

    …3 4 4 5 5 Last single digit in base 6 6 10 Out of digits - new position! 7 11 8 12 9 13 10 14 11 15 Out of digits again in the ones place 12 20 Two groups of six, zero ones See the pattern? It works…