Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab6f88b

Browse filesBrowse files
authored
Update fortune_cookie.py
1 parent 3bdc59b commit ab6f88b
Copy full SHA for ab6f88b

File tree

Expand file treeCollapse file tree

1 file changed

+28
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-3
lines changed

‎6-functions/fortune_cookie.py

Copy file name to clipboardExpand all lines: 6-functions/fortune_cookie.py
+28-3Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,43 @@
33

44
import random
55

6-
options = ['Don’t pursue happiness – create it.',
6+
options = [
7+
'Don’t pursue happiness – create it.',
78
'All things are difficult before they are easy.',
89
'The early bird gets the worm, but the second mouse gets the cheese.',
910
'If you eat something and nobody sees you eat it, it has no calories.',
1011
'Someone in your life needs a letter from you.',
1112
'Don’t just think. Act!',
1213
'Your heart will skip a beat.',
1314
'The fortune you search for is in another cookie.',
14-
'Help! I’m being held prisoner in a Chinese bakery!']
15+
'Help! I’m being held prisoner in a Chinese bakery!'
16+
]
1517

1618
def fortune():
17-
print(options[random.randint(0, len(options) - 1)])
19+
random_fortune = random.randint(0, len(options) - 1)
20+
21+
if random_fortune == 0:
22+
option = options[0]
23+
elif random_fortune == 1:
24+
option = options[1]
25+
elif random_fortune == 2:
26+
option = options[2]
27+
elif random_fortune == 3:
28+
option = options[3]
29+
elif random_fortune == 4:
30+
option = options[4]
31+
elif random_fortune == 5:
32+
option = options[5]
33+
elif random_fortune == 6:
34+
option = options[6]
35+
elif random_fortune == 7:
36+
option = options[7]
37+
elif random_fortune == 8:
38+
option = options[7]
39+
else:
40+
option = 'Error'
41+
42+
print(option)
1843

1944
fortune()
2045
fortune()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.