View Single Post
  #2 (permalink)  
Old 06-19-2007, 02:43 PM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,635
Last Blog:
CherryPy(thon)
Rep Power: 28
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

In Python it's called "lists".
You can access the lists using the index-operators, [].

Lists starts at zero (0) like arrays, and they work almost in the same way. So if you want to get the first element in the list do this [0], the next [1] and so on. You can also use more advanced operators and do like this [0:2] which will return the two first elements in the list like a new list - and if you don't want the first element as a f.ex. string you can get it as a list like this [0:1]. You can also access it both ways using [-x] or [-x:-x], etc.

Now you're probably confused if you don't know to all this, let's see an example:
Code:
l = ["apple", "banana", "orange"]

l[0] # Returns "apple"
l[1] # Returns "banana"

l[0:1] # Returns ["apple"]
l[0:2] # Returns ["apple", "banana"]
l[1:3] # Returns ["banana", "orange"]
__________________
05-03-2007 - 11-13-2008
Reply With Quote