Results for “in”

Showing 1–10 of 246

  1. Challenge

    Assignment in a condition

    An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.

    Fix the code Easy 3 stages if else == SyntaxError
  2. Challenge

    Logging instead of print

    …has a level and you decide which levels to show. Levels instead of prints Replace each print() with the logging call for its level: logging.debug() , logging.info() , logging.warning() or…

    Fix the code Medium 2 stages logging debug info warning
  3. Challenge

    Safe number input

    The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative…

    Write the code Easy 2 stages errors try except ValueError
  4. Challenge

    input() returns text

    A crew count read with input() crashes when 1 is added to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.

    Fix the code Easy 3 stages input int TypeError type conversion
  5. Challenge

    Index by ID

    …ID to its record, so any item 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.

    Write the code Medium 2 stages dictionaries indexing lookup in
  6. Challenge

    Missing index

    readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.

    Fix the code Easy 3 stages lists indexing IndexError len
  7. Article Mini projects

    Base 6 Number System in Python

    In Project Hail Mary, the alien engineer Rocky counts in base 6 because he has two hands with three fingers each. In this article, you'll build Python programs that convert between decimal, base-6…

  8. Article Python Fundamentals

    Nested Loops in Python

    Nested loops are simply a loop inside another loop. Sounds straightforward, but a lot of people get confused here. We use them when we need to go through multidimensional data - Excel tables, scanning…