77 f.close()
78
79
80def moon_chooser(moon, moons=["europa", "callisto", "phobos"]): 81 if moon is not None:
82 moons.append(moon)
83
58 return ImaginaryNumber()
59
60
61def main(options: dict = {}) -> str: 62 pdb.set_trace()
63 if "run" in options:
64 value = options["run"]
38 def limits(self):
39 return self.limits
40
41 def get_number(self, min_max=[1, 10]): 42 """Get a random number between min and max."""
43 assert all([isinstance(i, int) for i in min_max])
44 return random.randint(*min_max)
23 return all([is_prime(num) for num in nums])
24
25
26def store_paths(matrix: list[list[int]], i: int, j: int, path=[]) -> None:27 largest_element = 0
28
29 for row in set((i - 1, i, i + 1)):
Do not use a mutable like list
or dictionary
as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
def my_function(elem, l=[]):
l.append(elem)
return l
print(my_function(2)) # [2]
print(my_function(5)) # [2, 5]
def my_function(elem, l=None):
if l is None:
l = []
l.append(elem)
return l
print(my_function(2)) # [2]
print(my_function(5)) # [5]