swapping values in a list while looping through it.
Hi guys,
I have a list
List=[a,
and i want to swap values in turn:
eg:
1.st modification = [b,a,c,d,e,f,g,h]
2nd modification=
3rd modification =[a,b,d,c,e,f,g,h]
etc...
ideally I would actually like to create a new list that is:
new_List=
I am using the following method to swap them:
Temp=List[1]
List1=List[2]
List[2]=Temp
which works fine, however when I loop through the list it doesn't revert back to the original list since the values have now been swapped. Effectively it continues to swap the already swapped list. (I think the solution might lie in shallow copy versus deep copy, i tried using a 'placeholder' for the list with placeholder=
Thank you for the help, I am slowly (very very slowly) getting the hang of things
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask JD for more information if necessary.