Pybites Logo Rust Platform

Iterator Basics

Easy +2 pts

🎯 In Python, iteration is simple — for x in collection works on anything iterable, and you never think about whether you're borrowing or consuming the data:

nums = [1, 2, 3] for x in nums: print(x) # nums is still here — Python uses reference counting

You can also mutate in place:

nums[0] = 99 # direct index assignment

Rust has the same for x in collection syntax, but because there's no garbage collector, you …

Login to see the full exercise.