Example
String Methods - upper, lower, strip
Useful methods for working with text: changing case, removing whitespace.
Showing 11–20 of 65
Example
Useful methods for working with text: changing case, removing whitespace.
Challenge
Move the mission log's f-string into format_log(t, level, msg), a function that returns the line instead of printing it, then fix the alignment of every log line with one change inside the function.
Challenge
…the other kind of quotes inside, so they don't end the f-string. Readings on the right The board gets a third column: each system's temperature in °C. Numbers read best aligned to the right, so their…
Challenge
…log line like [T+00:12:05] INFO Engines nominal with an f-string, then build the timestamp from numbers with zero padding.
Example
Accessing individual characters and text fragments. Zero-based indexing in Python.
Challenge
…of an access code with * using len(), slicing and string repetition, then find a code inside a log line and mask it there before the line is saved.
Challenge
Check whether a mission log line contains ERROR with in, find where it starts with find(), including the -1 it gives when there is nothing to find, then slice out the error message.
Example
Searching, replacing and splitting text. Advanced string manipulation methods.
Challenge
…counts how many times the text appears. A multi-line string has a new line character, "\n" , between its lines, so there is one line more than there are new lines. Don't be fooled A new entry has come…
Challenge
…then put them back together in a new order with an f-string.