Insert a value to a list within a list - python -


say have following:

wholelist = ['a', 'b', ['1', '2', '4'], 'c', 'd'] 

how add value '3' numeric list within wholelist, @ point after value '2' before value '4'?

index correct sublist, use list's insert method.

wholelist[2].insert(2, '3') 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -