Hello friends, I am modifying the code in this ([https://www.codecademy.com/courses/learn-python-3/projects/python-magic-8-ball] exercise a bit.
I understood how conditional statements work, but I am trying to make this exercise such as, it should ask first to input ‘name’ and ‘question’ by user. And then move forward to random function and conditional statements. I tried using input() function in my code as well in first 2 lines. But it is not working as I want.
name = input() question = input() # name = 'Joe' # question = 'Will India win this match?' answer = '' import random random_number = random.randint(1,10) print(random_number) if random_number == 1: answer = 'Yes - definitely.' elif random_number == 2: answer = 'It is decidedly so.' elif random_number == 3: answer = 'Without a doubt.' elif random_number == 4: answer = 'Reply hazy, try again.' elif random_number == 5: answer = 'Ask again later.' 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: answer = 'Very doubtful.' elif random_number == 10: answer = 'Signs point to yes' else: answer = 'Error' if name == '': print('Question: ' + question) else: print(name +' asks: '+ question) if question == "": print("The Magic 8-Ball cannot provide a fortune unless you ask it something.") else: print(name +' asks: '+ question) print("Magic 8-Ball's answer: "+ answer)
Please can you help me doing this?