diff --git a/demo_code.py b/demo_code.py index 9fde50644..fa5a2b6a6 100644 --- a/demo_code.py +++ b/demo_code.py @@ -34,13 +34,17 @@ class RandomNumberGenerator: def limits(self): return self.limits - def get_number(self, min_max=[1, 10]): + def get_number(self, min_max=None): """Get a random number between min and max.""" + if min_max is None: + min_max = [1, 10] assert all([isinstance(i, int) for i in min_max]) return random.randint(*min_max) - def get_digits(self, min_max=[1, 10]): + def get_digits(self, min_max=None): """Get a random number between min and max.""" + if min_max is None: + min_max = [1, 10] assert all([isinstance(i, int) for i in min_max]) return random.randint(*min_max) @@ -48,7 +52,9 @@ def sum(self, a, b): return eval("a + b") -def main(options: dict = {}) -> str: +def main(options: dict = None) -> str: + if options is None: + options = {} pdb.set_trace() if "run" in options: value = options["run"] @@ -67,7 +73,9 @@ def main(options: dict = {}) -> str: f.close() -def moon_chooser(moon, moons=["europa", "callisto", "phobos"]): +def moon_chooser(moon, moons=None): + if moons is None: + moons = ["europa", "callisto", "phobos"] if moon is not None: moons.append(moon) diff --git a/hello.py b/hello.py index dc8227b07..d0d399dce 100644 --- a/hello.py +++ b/hello.py @@ -36,13 +36,17 @@ class RandomNumberGenerator: def limits(self): return self.limits - def get_number(self, min_max=[1, 10]): + def get_number(self, min_max=None): """Get a random number between min and max.""" + if min_max is None: + min_max = [1, 10] assert all([isinstance(i, int) for i in min_max]) return random.randint(*min_max) -def main(options: dict = {}) -> str: +def main(options: dict = None) -> str: + if options is None: + options = {} pdb.set_trace() if "run" in options: value = options["run"] @@ -61,7 +65,9 @@ def main(options: dict = {}) -> str: f.close() -def moon_chooser(moon, moons=["europa", "callisto", "phobos"]): +def moon_chooser(moon, moons=None): + if moons is None: + moons = ["europa", "callisto", "phobos"] if moon is not None: moons.append(moon)