← Back to Loops
Question 398
Grid Total
Grid Total
Four whole numbers are read, one per line, into a 2 by 2 grid declared as a list of lists (the first two lines make the first row). Use nested for loops: the outer loop takes one row at a time and the inner loop adds that row's values into a row total, which is printed as Row total: <value> before the next row starts; afterwards print the sum of everything as Grid total: <value>. Input: four integers, no prompts.
Expected Output:
Row total: 7 Row total: 11 Grid total: 18
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.