# Define a function running_total(n) using a while loop that starts count at 1 and total at 0

Canonical URL: <https://datadriven.io/problems/define-a-function-runningtotaln-using-a-while-loop-that-s-ae6040a5>

Domain: Python · Difficulty: medium

## Problem

Define a function running_total(n) using a while loop that starts count at 1 and total at 0. While count <= n, add count to total and increment count. Return total. Print running_total(10).

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/define-a-function-runningtotaln-using-a-while-loop-that-s-ae6040a5)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.