I wanted to separate a list into 2 separate lists. I had learned about the enumerate function to obtain both the index and the element and that helped a lot but I am having issues trying to correctly separate out this list.
so far my code shows
for i, element in enumerate(listExitPrice):
if element == "(None,)":
listBuyDatePT.insert(i, listBuyDate(i))
listStockNamePT.append(element)
listEntryPricePT.append(element)
listVolumePT.append(element)
listExitPricePT.append(element)
listSellDatePT.append(element)
else:
print (element)
listBuyDateAP.append(element)
listStockNameAP.append(element)
listEntryPriceAP.append(element)
listVolumeAP.append(element)
I am using test data right now, and when I print the listExitPrice I get
(Decimal('6.30'),)
(None,)
I can see that it does show that the first entry does show a value, and the second entry doesn't. However when I try to use an if-else statement to separate it out, it still only runs through the bottom loop only. Any guidance to fix this issue would be appreciated!
Aucun commentaire:
Enregistrer un commentaire