Reputation: 85
Got some example code:
var = [("f1","f2","f3"),("b1","b2","b3")]
print var
var[0][0] = var[0][0][1 : len(var[0][0])]
print var
if i wanted to replace "f1" with "1", how would i do that? thanks in advance!
Upvotes: 1
Views: 917
Reputation: 32199
You would have to assign the whole first element of the list a new tuple since tuples are immutable.
You would do that as follows:
var[0] = (var[0][0][1:],)+var[0][1:]
After this, the value of var will be:
[("1","f2","f3"),("b1","b2","b3")]
Upvotes: 4