Skip to content
Snippets Groups Projects
Commit 2eac91dd authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Split method into two parts in order to demonstrate expected exceptions.

parent eda69ca6
No related branches found
No related tags found
No related merge requests found
......@@ -39,19 +39,26 @@ class SmallestPositiveApp(App):
pass
@staticmethod
def _find_smallest_positive(entries):
smallest_positive = inf
def _extract_numbers(entries):
results = []
for entry in entries:
try:
value = float(entry)
if 0 < value < smallest_positive:
smallest_positive = value
results.append(value)
except ValueError:
pass
return results
@staticmethod
def _find_smallest_positive(values):
smallest_positive = inf
for value in values:
if 0 < value < smallest_positive:
smallest_positive = value
return smallest_positive
def on_entries(self, _, __):
self.result = SmallestPositiveApp._find_smallest_positive(self.entries)
self.result = SmallestPositiveApp._find_smallest_positive(SmallestPositiveApp._extract_numbers(self.entries))
def set_entry(self, index, entry):
self.entries[index] = entry
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment