Remember that indentation is very important in Python, as it uses it to tell were codeblocks are.
In an if/elif/else, all the ifs, elifs, and elses need to have the same indentation for the interpreter to associate them with each other.
import random
name = "Me"
question = "Can dogs fly?"
answer = " " #what is the use of this variable?
random_number = random.randint(1, 9)
if random_number == 1:
print("Yes - definitely")
elif random_number == 2:
print("It is decidedly so.")
elif random_number == 3:
print("Without a doubt.")
elif random_number == 4:
print("Reply hazy, try.") #shouldn't it be "Reply hazy, try again."?
elif random_number == 5:
print("Ask again later")
elif random_number == 6:
print("Better not tell you now.")
elif random_number == 7:
print("My sourcer say no.")
elif random_number == 8:
print("Outlook not so good.")
else:
print("Error") #answer = "error" won't work because answer isn't printed after it being given the value
This did end up working for indentations. Another place I failed was using print() statements instead of “answer =” like they wanted me to. In general, I should be using down arrow to move to the next line, not enter, right? as enter does the indentation and kept it going. Thank you!
You’re welcome! The down arrow key moves the cursor to the next line but, if there is no next line made yet it won’t work. I suggest enter and any number of backspace keys.