We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4e666b2 + a726721 commit 528c1ccCopy full SHA for 528c1cc
exercises/practice/resistor-color-expert/.meta/example.gd
@@ -30,5 +30,8 @@ func color_code(colors):
30
var tolerance = tolerances[colors[-1]] #work
31
for key in units.keys():
32
if total >= key:
33
- return "%s %s ±%s%%" % [(total / key), units[key], tolerance]
34
- return "%s ohms ±%s%%" % [total, tolerance]
+ return "%s %s ±%s%%" % [format_number(total / key), units[key], tolerance]
+ return "%s ohms ±%s%%" % [format_number(total), tolerance]
35
+
36
+func format_number(n):
37
+ return str(int(n)) if n == int(n) else str(n)
0 commit comments