Share your repls and programming experiences

← Back to all posts
Lab 3.01
Fbushra641 (8)

In this lab, we are making a Magic 8 Ball game. The user tells their name then asks a question. The computer will generate a random response from the list of 20 responses.

Comments
hotnewtop
LukeWright (114)

to make it more efficient and easier you could do:

import random
responses = ["It is certain.","It is decidedly so.","Without a doubt","Yes-- definately.","You may rely on it.","As I see it, yes.","Most likely."
print(random.choice(responses)

or even:

import random
responses = ["It is certain.","It is decidedly so.","Without a doubt","Yes-- definately.","You may rely on it.","As I see it, yes.","Most likely."
index = random.randint(0,len(responses) - 1)
print(responses[index])