Q:

python constructor

class GeekforGeeks: 
    geek = "" 
  
    # default constructor 
    def __init__(self): 
        self.geek = "GeekforGeeks"
  
    # a method for printing data members 
    def print_Geek(self): 
        print(self.geek) 
  
  
# creating object of the class 
obj = GeekforGeeks() 
  
# calling the instance method using the object obj 
obj.print_Geek() 
5
nuts = list("pecan nut", "walnut", "cashew nut", "macadamia nut")

forrests_favorites = list(nuts) # makes a new list with the same content
0
def __init__(self):
    # body of the constructor
1

New to Communities?

Join the community