Challenge
Log to a file
…4 log_file.readlines() gives a list of the lines, so len() counts them.
Showing 61–68 of 68
Challenge
…4 log_file.readlines() gives a list of the lines, so len() counts them.
Challenge
…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.
Challenge
…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.
Article Python Fundamentals
…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 without ever looking at the code inside. This…
Quiz
…Adding up and counting inside a loop enumerate() and range(len()) when you need positions Indentation inside the loop, break and a first nested loop How it works 15 questions: 11 with one correct…
Article Mini projects
…radii) print("Batch calculation results:") for i in range(len(names)): print(f"{names[i]}: {velocities[i]:.2f} m/s") What's Next? Now that you have a working calculator with NumPy, you can expand it…
Challenge
…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…
Challenge
…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…