[Tutor] Explanation of Lists data Type

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Thu Apr 13 12:29:02 CEST 2006


Alan Gauld schreef:
> list [-3:3]
> 
> which is an error but is not reported as such, rathger it returns 
> an empty list!

I don't think this is an error, and whether it returns an empty list or 
not depends on the length of the list:

 >>> for i in range(10):
	print i, range(i)[-3:3]

	
0 []
1 [0]
2 [0, 1]
3 [0, 1, 2]
4 [1, 2]
5 [2]
6 []
7 []
8 []
9 []


-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven



More information about the Tutor mailing list