Hello, how can I continually save the results of a loop computation into a single list element. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hello, how can I continually save the results of a loop computation into a single list element.

loops

18th Sep 2016, 10:21 AM
POZEIDON Thomas
POZEIDON Thomas - avatar
3 Answers
+ 4
Use append to add an element to the list.
18th Sep 2016, 10:31 AM
Zen
Zen - avatar
0
declare a variable and declare an another array increment the variable .....like result [ i ] = your ans and i++ ....where the results are stored
18th Sep 2016, 12:21 PM
Udhay Kumar
Udhay Kumar - avatar
0
my_list = [] #an empty list loop start #loop of your choice some_code_here my_list.append (thing to append each time through) print (my_list)
18th Sep 2016, 4:23 PM
Luke Armstrong