Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 7, 2022 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/89f64ad5286890d38c08050a02560c4a to your computer and use it in GitHub Desktop.
Save codecademydev/89f64ad5286890d38c08050a02560c4a to your computer and use it in GitHub Desktop.
Codecademy export
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