I've been going through the Python exercises on here and for the most part I actually 'get' it but while trying to do a very simple Magic 8-ball script I've run into an issue that I saw in exercises and never figured out. Code is below.
import random print ("Please enter a yes or no question and hit Return: ") question = input(" ") answer = random.randint(0,2) def reply(a): if answer == 0: print ("Yep") elif answer == 1: print ("Mebbe") elif answer == 2: print ("Nope") #return (a) print ("You asked:",question) print ("The answer is: ",reply)
The issue is probably obvious but I am oblivious to it. What is wrong with my function? Why does it not display an answer? I realise I haven't called the function in this bit as I've tried a few ways like
print (response) and clearly I don't know how to. I can get it to work without a function but part of my reason for doing this was to figure out how to use a function for this. Be gentle.