Skip to content

Commit 1f7f4ff

Browse files
committed
refactor(chapter10): simplify villain search logic in case_07_1.py
1 parent 641109c commit 1f7f4ff

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

chapter10/src/case07/case_07_1.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ def search_villains(people):
55
Args:
66
people: 검색할 사람들의 리스트
77
"""
8-
found = False
98
for p in people:
10-
if not found:
11-
if p == "joker":
12-
send_alert(p)
13-
found = True
14-
if p == "saruman":
15-
send_alert()
16-
found = True
9+
if p == "joker":
10+
send_alert(p)
11+
return
12+
if p == "saruman":
13+
send_alert(p)
14+
return
1715

1816

1917
def send_alert(p):

0 commit comments

Comments
 (0)