Does anyone have a clue how to fix this and make the program work smoothly?

#I've been trying to make a python module called math.py

def add(no1, no2):
    num = no1 + no2
    print num

def subtract(no1, no2):
    num = no1 - no2
    print num

# That all works fine but when I import it in to a new program:

import math
math.add(1, 1)
math.subtract(2, 1)

#It says AttributeError, no attribute 'add'

Recommended Answers

All 2 Replies

There's already a module named math in Python. You'll need to name yours something else.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.