0

How do you change a element in tuples?

27th Jun 2016, 9:24 AM
Jin AML
Jin AML - avatar
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)
18th Jul 2016, 3:09 PM
Subhankar Paul
Subhankar Paul - avatar
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...
31st Jul 2016, 11:36 AM
Aakash Sharma
Aakash Sharma - avatar
- 1
you don't
28th Jun 2016, 1:05 AM
Scott Youngblood
Scott Youngblood - avatar
- 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.
20th Aug 2016, 11:34 PM
Ryan