-
-
Save codecademydev/89f64ad5286890d38c08050a02560c4a to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random_number = random.randint(1, 9) | |
answer = '' | |
name = input('what is your name: ') | |
question = input('what is your question:') | |
if random_number == 1: | |
answer = 'yes - definitely' | |
elif random_number == 2: | |
answer = 'It is decidedly so' | |
elif random_number == 3: | |
answer = 'Without a doubt.' | |
elif random_number == 4: | |
answer = 'Reply hazy, try again.' | |
elif random_number == 5: | |
answer = 'Ask again later.' | |
elif random_number == 6: | |
answer = 'Better not tell you now.' | |
elif random_number == 7: | |
answer = 'My sources say no' | |
elif random_number == 8: | |
answer = 'Outlook not so good.' | |
elif random_number == 9: | |
answer = 'Very doubtful' | |
else: | |
answer = 'error' | |
if name == '': | |
print('Question: ' + question) | |
else: | |
print(name + ' asks ' + question) | |
print("Magic 8-ball's answer: " + answer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment