I have an assignment in which I have to map a name from the list to a specific integer in the array (hope I used the terminology correctly). I wrote this code but it is not working. Why is this so, and how can I make it work?
list_1 = ['sentosa', 'versicolor', 'virginica', 'virginica', 'sentosa']
beta = np.array([])
for x in list_1:
if x == "sentosa":
np.append(beta, [1], axis = 0)
elif x == "versicolor":
np.append(beta, [2], axis = 0)
elif x == "virginica":
np.append(beta, [3], axis = 0)