Results for “len”

Showing 41–45 of 45

  1. Challenge

    Log to a file

    …4 log_file.readlines() gives a list of the lines, so len() counts them.

    Write the code Easy 2 stages files open with write
  2. Challenge

    Debris grid

    …around: the outer loop goes over the column numbers, range(len(grid[0])) , and the inner loop over the rows, checking line[column] . A flag says whether the column was blocked.

    Write the code Medium 2 stages nested loops enumerate range strings
  3. Challenge

    Skip blanks and comments

    …C Parsed: 4, damaged: 1 Split into fields first, and when len(fields) != 4 , print the line, count it and continue . Count the parsed lines too, and print the totals after the loop.

    Write the code Medium 2 stages for loop continue strip startswith
  4. Challenge

    Search the log

    …Start the slice from where ERROR starts, plus its length, plus one for the space, and leave the end out. The time in brackets can grow longer, [T+100:02:00] , so work from position , not from a fixed…

    Write the code Medium 2 stages strings in find slicing
  5. Challenge

    Aligned status board

    …state, one per line. Because the names are all different lengths, the states end up scattered across the screen, and a HOLD is easy to miss. Line the states up in a column. Format specs can give each…

    Write the code Medium 3 stages f-strings alignment tables formatting