Challenge
Changed the caller's list
…the first line, prove both names share one list, fix it by returning a new list, then write a filter that leaves its input alone.
Showing 11–20 of 78
Challenge
…the first line, prove both names share one list, fix it by returning a new list, then write a filter that leaves its input alone.
Challenge
…parser from "Line to record" into parse_line(line), which returns the record dict, then let it return None for blank, comment and damaged lines so the loop only keeps real records.
Challenge
…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.
Article Python Fundamentals
…to write your own Python functions, from your first def to return values, default parameters and scope, with runnable examples, common mistakes and six practice projects.
Challenge
Write validate_cargo(item), which returns a list of everything wrong with a cargo record: missing fields and a negative mass, then a cargo ID that doesn't match the CG- and four digits format. An…
Challenge
…what crew.sort() gives back and store it, as text, in sort_returns . Then sort on a line of its own, print crew[0] , and store that name in first_after_sort . Remove any lines you added before you…
Example
Return can be used to exit function early when a condition is met.
Quiz
…and continue Functions: default values, keyword arguments, returning several values and variable scope How it works 20 questions: 15 with one correct answer, 5 where you select every correct answer…
Challenge
…to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.
Challenge
…calculation into a function distance_km(a, b) that returns the distance between two (x, y, z) points, and use it for all three waypoints. The output must stay exactly the same: To waypoint A: 193.0 km…