Challenge: Using the Range Function
Task
Swipe to start coding
- Use a
for
loop and therange
function to write the numbers from 1 to 9 (including 9) into the listresult
. - If the number is even, it should be squared.
- To check if a number is even, you can use an
if
statement and the conditioni % 2 == 0
.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 6