You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility
When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!
I am on learn python 3 Magic 8-Ball section of the course.
Whenever I run my code it rearranges the order of the print statement in a manner that doesn’t make sense. Here is my code,
import random name = "Jose" question = "Will I get another dog named Naruto?" answer = "" random_number = random.randint(1,9) #print(random_number) if random_number == 1: print("Yes - definitely.") elif random_number == 2: print("It is decidely so.") elif random_number == 3: print("Without a doubt.") elif random_number == 4: print("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 sources say no.") elif random_number == 8: print("Outlook not so good.") elif random_number == 9: print("Very doubtful.") else: answer = "Error" print(name + " asks; " + question) print("Magic 8-Ball's answer:" + answer)
Is there anything I could be doing better?
Thank you advance.
Learn Python 3 | Codecademy