Q:

python list 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
# empty list
print(list())

# vowel string
vowel_string = 'aeiou'
print(list(vowel_string))

# vowel tuple
vowel_tuple = ('a', 'e', 'i', 'o', 'u')
print(list(vowel_tuple))

# vowel list
vowel_list = ['a', 'e', 'i', 'o', 'u']
print(list(vowel_list))
1

New to Communities?

Join the community