# Learn Python 3- Magic 8 Ball

Hi,

This is my first time using this forum, so sorry if I come across unprofessional. It is regarding the ‘Magic 8 ball’ on Control flow. https://www.codecademy.com/courses/learn-python-3/projects/python-magic-8-ball

On Step 13, the task explores the what if’s, and asks to create a code for when the variable ‘name’ is empty. I have tried implementing that point using a if statement.

if name == “”:
print("Question " + question)

else:
print(name + " asks: " + question)

However this just causes the code to be replicated again. I have posted a copy of my code, and would be eternally grateful for any help!

import random
random_number = random.randint(1, 10)
#prints out random numbers from 1-10

name =“Belle”

question = “Will I have a good day tomorrow?”

if random_number == 1:

elif random_number == 2:
answer = “It is decidedly so”

elif random_number == 3:

elif random_number == 4:

elif random_number == 5:

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:

elif random_number == 10:

else:
print(“Error”)

if name == “”:
print("Question " + question)

else:
print(name + " asks: " + question)

print(name + " asks: " + question)

your code is repeating because you have 2 prints hehe

1 Like

Oh ofc, how did I miss that, thanks so much!

np, happens to me all the time

import random
name - “Akeem”
question = “Do you like me?”

random_number = random.randiant(1,9)

if random_number == 1:

elif random_number == 2:

elif random_number == 3:

elif random_number == 4:

elif random_number == 5:

elif random_number == 6:

elif random_number == 7:

elif random number == 8:
``````print(name +"asks" + question)