Example
Methods find, count, replace and split
Searching, replacing and splitting text. Advanced string manipulation methods.
Showing 1–10 of 28
Example
Searching, replacing and splitting text. Advanced string manipulation methods.
Challenge
…Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.
Challenge
Replace all but the last four characters 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
…it prints: Command: [abort burn] Matches abort burn: True replace("_", " ") swaps every underscore for a space. Add it, and one for dashes, to the end of the chain.
Example
Useful methods for working with text: changing case, removing whitespace.
Challenge
Build eng-2_2026-03-14.csv from a sensor ID and a date, then turn a name like Star Tracker A into a safe file name, and put the file in a folder of its own.
Challenge
Refactor the level counter from "Entries per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with…
Challenge
The tank check is full of prints left over from debugging. Replace them with logging calls at the right levels, so debug records stay hidden until switched on, then give the fuel code its own named…
Challenge
Replace a nine-branch elif that maps planets and the Moon to surface gravity with a dict and one get() lookup, keeping the output exactly the same, then loop over the dict for a weight table.
Challenge
Replace three copy-pasted tank-status blocks with a list of (name, level) pairs and one loop, keeping the output exactly the same, then add a fourth tank with a single list item and list the low…