list=[1,2,3,4,5,6,7,8,9]For every third number of my list, how to add 3 to it and print | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

list=[1,2,3,4,5,6,7,8,9]For every third number of my list, how to add 3 to it and print

17th Oct 2021, 2:55 PM
G-5256
G-5256 - avatar
8 Answers
+ 3
yeah I put dange and then get out successfully Thanks again!!! 💜💜
17th Oct 2021, 4:03 PM
G-5256
G-5256 - avatar
+ 6
myList = [1,2,3,4,5,6,7,8,9] for i in range(2,9,3): myList[i] += 3 print(myList)
17th Oct 2021, 4:02 PM
JaScript
JaScript - avatar
+ 3
In a loop over each third item index
17th Oct 2021, 3:09 PM
JaScript
JaScript - avatar
+ 1
Yor r absolutely right but i don't want to insert 3 Iist, increment 3rd index by 3 i.e if I have 4 on index 3 so i want ans as 4+3
17th Oct 2021, 3:36 PM
G-5256
G-5256 - avatar
+ 1
thank u ❤
17th Oct 2021, 3:55 PM
G-5256
G-5256 - avatar
0
l=[1,2,3,4,5,6,7,8,9] for i in l[::3]: l[i]=l[i]+3 print(l)
19th Oct 2021, 12:42 PM
Abhishek Kumar
Abhishek Kumar - avatar
0
Thanks🙂
27th Oct 2021, 12:15 AM
G-5256
G-5256 - avatar
- 2
Hi
19th Oct 2021, 7:57 AM
Bhola Nath Dahal
Bhola Nath Dahal - avatar