๐Ÿ PyQuest๐Ÿงบ Lists & Collections ยท ๐Ÿ”ฎ Magic 8-Ball
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Magic 8-Ball ๐Ÿ”ฎ

Time to give your programs a mind of their own. Python has a toolbox called random โ€” you unlock it with one line at the top of your file:

import random

Then you get two brilliant powers:

random.choice() picks a random item out of a list:

flavors = ["vanilla", "mint", "mango"]
print(random.choice(flavors))    # โžœ a different one each run!

random.randint(a, b) gives a random whole number between a and b (both ends included) โ€” perfect for dice:

print(random.randint(1, 6))      # โžœ 1, 2, 3, 4, 5 or 6

Run your program a few times and watch the answers change. ๐ŸŽฒ

Your mission

Build a magic 8-ball fortune teller!

  1. import random at the top
  2. Make a list called answers with at least 6 mysterious replies
  3. Use input() to ask the user for their question
  4. Print a reply picked with random.choice(answers)
  5. Print a certainty percentage using random.randint(1, 100)

Then run it again. And again. It's different every time! ๐Ÿ”ฎ

Your code

Press โ–ถ Run to see what your code does!