How to replace an element at specific index in tuple with Python

1 Answer

0 votes
tpl = (87, 234, 4, 9813, 99)
  
idx = 3
tpl = tpl[ : idx] + (100 ,) + tpl[idx + 1 : ]
  
print(tpl)
  
  
  
'''
run:
  
(87, 234, 4, 100, 99)
  
'''

 



answered Jan 29, 2020 by avibootz
edited Jan 29, 2020 by avibootz

Related questions

1 answer 203 views
1 answer 200 views
2 answers 205 views
1 answer 185 views
1 answer 184 views
2 answers 312 views
...