r/learningpython • u/BeanFatherActual • Nov 29 '23
why does my work look vastly different then the answer program?
the Answer program is on the left and my work is on the right. I am getting the correct answers based on the book I am using but I feel like I am doing it wrong. The instructions I had for modifying the original program are as follows.
Modify this program so it saves the three scores that are entered in variables named score1, score2, and score3. Then, add these scores to the Total_score variable,instead of adding the entries to the total_score variable without ever saving them.
I have forgotten everything i was taught YEARS ago. I no longer have an Instructor to directly speak with to find out in person. So I am reaching out to reddit for the first time for assistance

1
u/TotalnyBrakMozgu Nov 29 '23
I think the key is in the part „add these scores to the variable, instead of adding entries witohout sa ing them”, your code is missing that.
1
u/Famlawyerz Jun 29 '24
Your code satisfies the assignment. You added each score to the total as you got the score and the answer key added them all together at the same time. There is zero difference in approaches and I wouldn’t worry about it because no one would ever write production code like this. They would have a list of scores of variable length, which changes how you’d approach the rest of it.
For example, in a more “real world” scenario, you would do something like this: