Tell us what’s happening:
How do I prevent ModuleNotFoundError, and import mathparse? Or is there another way to solve this problem without having to create my own parser? Thank you.
Your code so far
from mathparse import mathparse
def is_valid_equation(equation):
sum = equation.split(" = ")[0]
answer = int(equation.split(" = ")[1])
print(sum, answer)
sum = mathparse.parse(sum)
return sum == answer
is_valid_equation("2 + 9 / 3 = 5")
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
Challenge Information:
Daily Coding Challenge - Equation Validation
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-04-04