My goal is to get a list of Objects named recursively dynamically. This is the code I tried.
I want the object_list
to be [Object_0, Object_1, Object_2, Object_3, Object_4]
object_list = []
class Object(object):
size = ""
price = ""
def create_object_list(object_list):
for num in range(5):
Object_%s = Object() %num
object_list.append(Object_%s)
return object_list
This is the error:
Object_%s = Object() %num
SyntaxError: can't assign to operator