r/AskProgramming • u/Cold_Abrocoma7320 • Oct 11 '26
For loop
How would I store 3 different answers to the same 3 questions asked using a for loop. I know how to store one answer, but not all three while still using the for loop
0
Upvotes
View all comments
5
u/OneMathematician1757 Oct 11 '26 edited Oct 11 '26
You need to instantiate a data structure outside the scope of the loop in order to retain the data between the loop iterations. There are various data structures to hold multiple data elements as the other commenters have shown.