Python: For loop to iterate class object

0 votes

How i can store multiple class object through looping?

May 22 in Python by Hiran
11 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Refer to the below code:

class Try:    
    def do_somthing(self):        
          print 'Hello'

if __name__ == '__main__':
    obj_list = []
    for obj in range(10):
        obj = Try()
        obj_list.append(obj)

obj_list[0].do_somthing()
answered May 22 by Raj

Related Questions In Python

0 votes
1 answer

Shorter way to write a Python for loop

You can use the enumerate iterator: for i, ...READ MORE

answered Jan 17 in Python by SDeb
• 11,080 points
18 views
0 votes
1 answer

Python class inherits an object

Python 3.x: class MyClass(object): = new-style class class MyClass: ...READ MORE

answered Apr 17, 2018 in Python by anonymous
72 views
0 votes
1 answer

What's the canonical way to check for type in Python?

To check if o is an instance ...READ MORE

answered Aug 24, 2018 in Python by Priyaj
• 56,140 points
19 views
0 votes
1 answer

Python class inherits object

Python 3.x: class MyClass(object): = new-style class class MyClass: = new-style ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 56,140 points
52 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
69 views
+4 votes
6 answers
0 votes
1 answer

How to use for loop in Python?

There are multiple ways of using for ...READ MORE

answered Mar 4 in Python by Priyaj
• 56,140 points
13 views
+1 vote
1 answer

What is the correct order to learn concepts in Python for machine learning?

Machine Learning is a vast domain. It ...READ MORE

answered Jul 25, 2018 in Python by ANMOL
• 3,620 points
44 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.