14 try it , 2 codes


#1



#this code didn't work 
squares=[i**2 for i in range(11)]
print filter(lambda x:x >=30 and x <=70,squares)

#but this did :

squares=[i**2 for i in range(1,11)]
print filter(lambda x:x >=30 and x <=70,squares)


aren't they the same ? what is the different between range(11) and range(1,11) ??


#2

range(11) works the same as range(0, 11).

You don't see difference between these two snippets because of the conditions (x >=30 and x <=70).

squares=[i**2 for i in range(11)]
print squares
# ==> [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

squares=[i**2 for i in range(1,11)]
print squares
# ==> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

SCT (submission correctness test) is pretty strict and this is the reason why your first code wasn't accepted.


#3

** I get that range(11) is from 0 to 10 and range(1,11) from 1 to 10 .


#4

Yes, exactly! :slight_smile:

0 is the default starting point of the range.