i'm a new comer to this language. can anybody tell me why this simple piece of code gives me an error indicating that "NameError,name 'example' is not defined". by the way i use Wing IDE to write my codings.

class example():
def _init_ ():
print("a class is created")

def m1 ():
print("a method")

ex1 = example()
ex1.m1()

pls help me out

def m1():

should be

def m1(self):

to make it an instance method of the class.

Take a look at this tutorial, especially the references to "self".

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.