Urgh, I figured out what I was doing wrong! The problem was that I was directly doing the replacing with a tuple and Python kept on saying that I can't assign it to an object. I tried copying the tuple value to a different variable and it worked out fine. Thanks everyone for their help and I highly appreciate it.