I have a list in python :
['ABCD_BAND1.TXT', 'ABCD_BAND2.TXT', 'ABCD_BAND3.TXT', 'ABCD_BAND4.TXT', 'ABCD_BAND5.TXT', 'ABCD_BAND6.TXT', 'ABCD_BAND7.TXT']
I want to pick ABCD_BAND4.TXT & ABCD_BAND5.TXT and define them as two new variables and do my analysis based on these two variables. I have written the following code but it does not works
Assign Variables
dataList = ['ABCD_BAND1.TXT', 'ABCD_BAND2.TXT', 'ABCD_BAND3.TXT', 'ABCD_BAND4.TXT', 'ABCD_BAND5.TXT', 'ABCD_BAND6.TXT', 'ABCD_BAND7.TXT']
for item in dataList:
if item.endswith("BAND4.TXT"):
Item = "band4"
for item in dataList:
if item.endswith("BAND5.TXT"):
Item = "band5"
How can I fix it?
Cheers
Itemis first set to "band4" in the first loop and thenItemis set to "band5" in the second loop. Do you just need to use two different names, sayitem1anditem2?