0
How do you change a element in tuples?
4 odpowiedzi
+ 3
yes u can change via:
suppose t=('100','200','300','400')
1st convert the tuple to list i.e. lst = list(t)
change the value i.e. lst[0] = '300'
again convert it to tuple i.e. t = tuple(lst)
0
no elements in a tuples cannot be changed and that is why it is written in that lesson........
list's elements can be changed
dictionary's elements can also be changed
but sorry
cycles can't be changed that is why they are faster than lists
hope you would understand......
have a nice day...
- 1
you don't
- 1
make a new tupple and reassign the variable.
This is how string functions work, as strings are immutable also. for example:
str1="123"
str2="456"
str1=str1+str2
there are three immutable strings("123", "456", "123456"), and the variable str1 is assigned one, then gets reassigned another.