forked from Mrinank-Bhowmick/python-beginner-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoketeller.py
More file actions
64 lines (59 loc) · 1.95 KB
/
joketeller.py
File metadata and controls
64 lines (59 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import requests
import time
tellajoke = True
category = "Any"
lang = "eng"
while tellajoke:
ans = str(
input("\n\nDo you want to read a joke?(y => yes; n => exit; s=> settings): ")
)
if ans == "y":
x = requests.get("https://v2.jokeapi.dev/joke/" + category + "?lang=" + lang)
x = x.json()
if "joke" in x:
print("\n" + x["joke"])
else:
print("\n" + x["setup"])
print("...")
time.sleep(1)
print(x["delivery"])
elif ans == "s":
s_ans = str(
input(
"Which settings would you like to edit? (c => category, l => language): "
)
)
if s_ans == "c":
print("Current selected category: " + category + "\n")
c_ans = str(
input(
"Selectable categories:\n a => Any\n p => Programming\n m => Misc\n d => dark\n s => "
"Spooky\n c => Christmas\n > "
)
)
if c_ans == "p":
category = "Programming"
elif c_ans == "m":
category = "Misc"
elif c_ans == "d":
category = "Dark"
elif c_ans == "s":
category = "Spooky"
elif c_ans == "c":
category = "Christmas"
elif c_ans == "a":
category = "Any"
print("Category " + category + " set!")
elif s_ans == "l":
print("Current selected language: " + lang)
l_ans = str(
input(
"Selectable languages:\n en => English\n cs => Czech\n de => German\n es => Spanish\n fr => "
"French\n pt => Portuguese\n > "
)
)
if l_ans in ["en", "cs", "de", "es", "fr", "pt"]:
lang = l_ans
print("Language " + lang + " set!\n")
else:
tellajoke = False