I'm writing a for-loop to create a list of characters ('e' for edible, 'p' for poisonous) from a binary list (1 corresponding to 'p', and 0 corresponding to 'e'). When I try to do this, everyone gets evaluated to 'e'.
for val in predictions:
if predictions[val] == 1:
toAnswer.append('p')
else:
toAnswer.append('e')
I'm expecting a mix of 'p' and 'e', but when I print out my toAnswer list, it's filled entirely with 'e's. I also printed out my predictions list and it showed a mixture of 1s and 0s. Where am I going wrong?
Aucun commentaire:
Enregistrer un commentaire