Skip to content

Commit a726721

Browse files
committed
Update resistor-color-expert example to pass on Godot Engine v4.4.1.stable.official.49a5bc7b6 (cf. #38)
1 parent 8d20737 commit a726721

File tree

1 file changed

+5
-2
lines changed
  • exercises/practice/resistor-color-expert/.meta

1 file changed

+5
-2
lines changed

exercises/practice/resistor-color-expert/.meta/example.gd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ func color_code(colors):
3030
var tolerance = tolerances[colors[-1]] #work
3131
for key in units.keys():
3232
if total >= key:
33-
return "%s %s ±%s%%" % [(total / key), units[key], tolerance]
34-
return "%s ohms ±%s%%" % [total, tolerance]
33+
return "%s %s ±%s%%" % [format_number(total / key), units[key], tolerance]
34+
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

Comments
 (0)