Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Compute Running Total

Practice accumulating values across a list to produce running totals.

Python practice8 minLoops & IterationBeginnerLast updated March 15, 2026

Problem statement

Given a list of integers nums, compute the running total list where the i-th element of the result is the sum of nums[0] through nums[i]. Use loops to iterate the input list and accumulate the sum incrementally.

Task

Given a list of numbers, return a new list where each element is the running total up to that index.

Examples

Basic running total

Input

compute_running_total([1, 2, 3])

Output

[1, 3, 6]

The running totals are 1, 1+2=3, 1+2+3=6.

Input format

A single function call compute_running_total(nums) where nums is a list of integers.

Output format

Return a list of integers representing the running totals.

Constraints

0 <= len(nums) <= 10000. Each number fits in Python's integer type.

Samples

Sample 1

Input

compute_running_total([5, -2, 7])

Output

[5, 3, 10]

Running totals: 5, 5+(-2)=3, 3+7=10.