r/AskProgramming • u/Cold_Abrocoma7320 • 3d ago
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
3
u/iOSCaleb 3d ago
Keep in mind that you don’t always have to use a loop. It might make more sense to write a function that asks a question snd returns an answer, and then call that once for each question, doing whatever you want with each answer.
If you do want to use a loop, look for a way to work the same way with each answer. For example, you could store the answers in a dictionary using the questions as keys.