Q:

How to switch elements for any given list?

Lets say I have a list: ["5", "6", "4", "3"]
What I want to do is replace any char "5" with "6" and replace "6" with "5". 
So the list would look like this in the end: 
["6", "5", "4", "3"]

I want to do this for all lists that may be inputted. This means that not all lists will have the elements "5" and "6" in them, but I want to switch the 5's and the 6's for the lists that do. 
Note: The elements in the list are string elements. Not integers. 
I've been thinking of using if statements and .replace() but that changes the 5 and 6, but then changes it back. 
Examples:
if "5" in list1:
    list1.replace("5", "6")
if "6" in list1:
    list1.replace("6", "5")

As you can see, that just replaces it back. It doesn't work. It would be great if someone could help me solve this. 
Note: If the element is "1532" in a list, the 5 in that should also be replaced with a string. Vice versa for 6's as well.
Another Example: 
firstlist = ["125", "673", "222", "65"]`

Output: 
firstlist = ["126", "573", "222", "56"]

A:

Under the assumption there are no underscores and tabs in your lists, this can work:
>>> list1 = ["126", "573", "222", "56"]
>>> str1 = "\t".join(list1)
>>> str1.replace("5", "_").replace("6", "5").replace("_", "6").split('\t')
['125', '673', '222', '65']

A:

Here's a general function that performs the swaps by iterating over chars in strings and keying into a dict to locate the partner for each swappable element. This technique can scale to any number of arbitrary swaps you want to include; just make the swaps dict a parameter instead of x and y.
>>> def swap_all(lst, x, y):
...     swaps = {x: y, y: x}
...     return ["".join(swaps.get(c, c) for c in e) for e in lst]
...
>>> swap_all(["125", "64", "1", "5", "4", "65", "6"], "5", "6")
             ['126', '54', '1', '6', '4', '56', '5']

