Hi@Noman,

You created two empty list. And in the for loop you tried to append values in your list. But in the last part you tried to convert your list into numpy array using the **same variable name**. So I suggest you to change your variable name as given below.

prets = []
pvols = []
for p in range (2500):
weights = np.random.random(noa)
weights /= np.sum(weights)
prets.append(np.sum(rets.mean() * weights) * 252)
pvols.append(np.sqrt(np.dot(weights.T,
np.dot(rets.cov() * 252, weights))))
pret = np.array(prets)
pvol = np.array(pvols)

Make this changes in your code and try once again.