Skip to content

Commit

Permalink
feat: makes the Python Substitute Algorithm refactoring solution more…
Browse files Browse the repository at this point in the history
… simple (#115)

* feat: makes the refactoring solution more simple

The first ambition was to make the example more pythonic (using for i in `range(len(my_list))` is considered bad practice against `for element in my_list`) and then I just managed to simplify further.

* fix: change name of the returned variable
  • Loading branch information
cmnemoi authored Sep 6, 2022
1 parent 75f1ec9 commit b880340
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions simple/python/substitute-algorithm_after.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
def foundPerson(people):
candidates = ["Don", "John", "Kent"]
for i in range(len(people)):
if people[i] in candidates:
return people[i]
return ""
return people if people in candidates else ""

0 comments on commit b880340

Please sign in to comment.