Skip to content

Commit 8f0defa

Browse files
committed
added search term
1 parent 5fb512d commit 8f0defa

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

code/kaceyb/python/lab08/lab_08.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PART 1 #
22

33

4+
from logging import exception
45
import requests
56

67

@@ -30,7 +31,8 @@
3031

3132

3233
response = requests.get(
33-
f"https://icanhazdadjoke.com/search?page=1", headers={"Accept": "application/json"}
34+
f"https://icanhazdadjoke.com/search?term={search_term}",
35+
headers={"Accept": "application/json"},
3436
)
3537

3638
# print(response)
@@ -39,9 +41,13 @@
3941

4042
joke = response.json()
4143
jokes = joke["results"]
44+
try:
4245

43-
for joke in jokes:
44-
print(joke["joke"])
45-
another_joke = input("Want another joke? yes/no: ").lower()
46-
if another_joke == "no":
47-
break
46+
for joke in jokes:
47+
print(joke["joke"])
48+
another_joke = input("Want another joke? yes/no: ").lower()
49+
if another_joke == "no":
50+
break
51+
52+
except exception as e:
53+
print(f"error {e}")

0 commit comments

Comments
 (0)