From 78520801ea1fd0e2427760675bb72757610ae574 Mon Sep 17 00:00:00 2001 From: Josh Mudge Date: Wed, 30 Jan 2019 21:12:24 -0700 Subject: [PATCH] Manipulated numbers. --- Codecademy.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Codecademy.md b/Codecademy.md index 99c34fa..de19028 100644 --- a/Codecademy.md +++ b/Codecademy.md @@ -300,6 +300,20 @@ You can manipulate lists with list comprehensions as well: fahrenheit = [celsius * (9 / 5) + 32 for celsius in celsius] ``` +### Print manipulated numbers in for loop +``` +single_digits = range(10) +squares = [] +cubes = [(num ** 3) for num in single_digits] + +for single_digits in single_digits: + print(single_digits) + squares.append(single_digits ** 2) + +print(squares) + +print(cubes) +``` ## Ranges You can get a range of numbers using `range()`