Python Week3 Lecture1 Handout
Python Week3 Lecture1 Handout
PROGRAMMING,
DATA STRUCTURES AND
ALGORITHMS IN PYTHON
Week 3, Lecture 1
for i in [0,1,2,3,4,5,6,7,8,9]:
for i in range(0,10):
Is range(0,10) == [0,1,2,3,4,5,6,7,8,9]?
In Python2, yes
In Python3, no!
range() and lists
Can convert range() to a list using list()
list(range(0,5)) == [0,1,2,3,4]
str(78) = "78"
int("321") = 321