import numpy as np
class test:
def __init__(self, num1, num2):
self.num1 = num1
self.num2 = num2
arr = []
for i in range(10):
x = np.random.uniform(0, 5, 2)
t = test(x[0], x[1])
arr.append(t)
print(arr[:].num1)
This gives me the error 'list' object has no attribute num1.
If I instead use a for loop to cycle through the list, then it prints out just fine:
for i in range(len(arr)):
print(arr[i].num1)
What gives?