0
import random

def multiply():
    num1 = random.randint(1,12)
    num2 = random.randint(1,12)
    ans = int(input("What is the answer to " + str(num1) + " x " + str(num2) + " ? "))
    correct = (ans == num1 * num2)
    if correct:
        print("You are correct! ")
    else:
        print("Wrong, please try again. ")
    return correct

def addition():
    num1 = random.randint(1,12)
    num2 = random.randint(1,12)
    ans = int(input("What is the answer to " + str(num1) + " + " + str(num2) + " ? "))
    correct = (ans == num1 + num2)
    if correct:
        print("You are correct! ")
    else:
        print("Wrong, please try again. ")
    return correct

name = input("What is your name? ")
maths = input("What mathematics would you like to learn, " + name + "? ")
if maths == "Multiplication" or "m" or "x":
    correct = multiply() 
elif maths == "Addition" or "a" or "x":
    correct == addition() 

I am having trouble getting the second 'def addition' to work. The first 'def multiply' works and runs correctly, however the 'def multiply' still won't work.

Any thoughts on how I can make this work?

Ryan Jones
  • 75
  • 1
  • 5

1 Answers1

2

change == to = as it is assignment

 correct = addition() 
Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78