The Magic 8 Ball is a toy that gives random answers to yes/no questions. Let's build one!
We'll combine random.randint() with if/elif/else to pick a random response.
import random
num = random.randint(1, 9)
if num == 1:
print('Yes, definitely.')
# ... add more responses
Use random.randint(1, 9) to get a random number. Then use if/elif/else with different ranges to give different fortunes. Think of a Magic 8 Ball!
⚠️ Try solving it yourself first — you'll learn more!
import random
num = random.randint(1, 9)
if num == 1:
print('Yes, definitely.')
# ... add more responses