Skip to content

Update 29_fortune_cookie_2.py #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 18 additions & 38 deletions 6-functions/29_fortune_cookie_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,25 @@
# Codédex

import random

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

def fortune():
random_fortune = random.randint(0, len(options) - 1)

if random_fortune == 0:
option = options[0]
elif random_fortune == 1:
option = options[1]
elif random_fortune == 2:
option = options[2]
elif random_fortune == 3:
option = options[3]
elif random_fortune == 4:
option = options[4]
elif random_fortune == 5:
option = options[5]
elif random_fortune == 6:
option = options[6]
elif random_fortune == 7:
option = options[7]
elif random_fortune == 8:
option = options[8]
random_fortune = random.randint(0,7)
if random_fortune==0:
print("Don't pursue happiness – create it.")
elif random_fortune==1:
print("All things are difficult before they are easy.")
elif random_fortune==2:
print("The early bird gets the worm, but the second mouse gets the cheese.")
elif random_fortune==3:
print("Someone in your life needs a letter from you.")
elif random_fortune==4:
print("Don't just think. Act!")
elif random_fortune==5:
print("Your heart will skip a beat.")
elif random_fortune==6:
print("The fortune you search for is in another cookie.")
else:
option = 'Error'
print("Help! I'm being held prisoner in a Chinese bakery!")
fortune()

print(option)

fortune()
fortune()
fortune()