From 43333db8254542f46ae0eaa012c24592ce381aa2 Mon Sep 17 00:00:00 2001 From: Noelle Leigh Date: Sun, 3 Mar 2024 17:39:21 -0500 Subject: [PATCH] Round growth rate to single decimal At generation 8, the growth rate in the "look" message is displayed as: > 2.4000000000000004x To make it display "2.4x" instead, I used the [format specification][0] to display growth rate with only a single decimal place. [0]: https://docs.python.org/3/library/string.html#format-specification-mini-language --- menu_screen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu_screen.py b/menu_screen.py index ac91088..01b8080 100644 --- a/menu_screen.py +++ b/menu_screen.py @@ -564,7 +564,7 @@ class CursedMenu(object): # get plant description before printing output_string = self.get_plant_description(this_plant) growth_multiplier = 1 + (0.2 * (this_plant.generation-1)) - output_string += "Generation: {}\nGrowth rate: {}x".format(self.plant.generation, growth_multiplier) + output_string += "Generation: {}\nGrowth rate: {:.1f}x".format(self.plant.generation, growth_multiplier) self.draw_info_text(output_string) self.infotoggle = 1 else: