Yashotantra Academy
AI · Blockchain · Cloud · Data
Dark mode active
Learn
Tracks
ABCD
Certification
More
▾
Dark mode active
Learn
Tracks
ABCD
Certification
Study
Theory
Code Lab
Build
Solidity IDE
Staking Sandbox
Simulation
Reference
Wallets
Gas Fees
Explorers
← Code Lab
Python
0/50 solved · 0%
All lessons
lesson
code
Control flow · easy
5. for loops and range
Repeat work over a range.
Write `sum_to(n)` returning `1 + 2 + ... + n` using a `for` loop over `range`.
Required in your answer:
for
range(
Reveal solution
Run & check
Reset
Runs via Pyodide
def sum_to(n): # TODO total = 0 return total
Output appears here.
← 4. if / elif / else
6. Lists →