I wrote this script:
soilMod = ['ptaaco']
n = 2
soilModSplit = [soilMod[i:i+n] for i in range(0, len(soilMod), n)] # This returns ['pt', 'aa', 'co']
alphaTest = soilModSplit # I want to maintain the original list built before I remove items below. This returns ['pt', 'aa', 'co'] as well
if 'pt' in soilModSplit:
soilModSplit.remove('pt')
print soilModList # This returns ['aa', 'co']
print alphaTest # This also returns ['aa', 'co'] It's missing the original ['pt', 'aa', 'co'] and I didn't ask the script to remove it from this particular list.
For some reason, when I remove the item ('pt') from soilModSplit, it also removes the item from alphaTest. Is this the expected result? It seems like any variable built on the soilModSplit (in this case, alphaTest) is dependent on any action taken on the soilModSplit. Maybe I am doing something wrong? Is there a way to work around this?
Thanks, Mike