File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
1
# PART 1 #
2
2
3
3
4
+ from logging import exception
4
5
import requests
5
6
6
7
30
31
31
32
32
33
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" },
34
36
)
35
37
36
38
# print(response)
39
41
40
42
joke = response .json ()
41
43
jokes = joke ["results" ]
44
+ try :
42
45
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 } " )
You can’t perform that action at this time.
0 commit comments