This is what I intended to do

class person:
 "class to represent a person"
def _init_(self):
    self.name = ""
    self.age = 0.0
    self.sqr_age = 0
    
class ageName:
    def listAgeName(x,y):
    # x is name
    # y is age
        x = 0
        y = 0
listAgeName = [('John', 18)]    
    
p = person()
g = ageName()
p.age = ageName(y)
p.name = ageName(x)

I want to make a new class. So when I have a group of list
list1 = [('X',y), ('X2',y2)]
I can assign each x to p.age and each y to p.name,..

What did I do wrong here?
Thanks

here are some tips. First off, after stating class person, you must have three spaces for each following line. 3 for each semicolon. As for init, it needs two under scores __ like so:

class person:
   def __init__(self):
      print('__init__ not _init_  :)')

just like functions, classes can pass arguments. Use __init__ to get arguements like so:

def func(arg1):
   print arg1

'essentially passing arguements are the same with __init__'

class person:
   def __init__(self,name,age):
      self.name = name
      self.age = age

also, all functions in a class must have the argument 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.