Part lets you pick out an element of a list.

Part[{a,b,c,d,e,f,g},2]

[[ ... ]] is an alternative notation.

{a,b,c,d,e,f,g}[[2]]

{a,b,c,d,e,f,g}[[-2]]

You can ask for a list of parts by giving a list of part numbers.

{a,b,c,d,e,f,g}[[{2,4,5}]]

;; lets you ask for a span or sequence of parts.

{a,b,c,d,e,f,g}[[2;;5]]

Take[{a,b,c,d,e,f,g},4]

Take[{a,b,c,d,e,f,g},-2]

Drop[{a,b,c,d,e,f,g},-2]

Let’s now talk about lists of lists, or arrays. Each sublist acts as a row in the array.

{{a,b,c},{d,e,f},{g,h,i}}//Grid

{{a,b,c},{d,e,f},{g,h,i}}[[2]]

{{a,b,c},{d,e,f},{g,h,i}}[[2,1]]

It’s also often useful to pick out columns in an array.

{{a,b,c},{d,e,f},{g,h,i}}[[All,1]]

The function Position finds the list of positions at which something appears.

Position[{{a,b,c},{d,e,f},{g,h,i}},d]

Position[{{x,y,x},{y,y,x},{x,y,y},{x,x,y}},x]

Position[Characters["The Wolfram Language"],"a"]

Flatten[Position[IntegerDigits[2^500],0]]

The function ReplacePart lets you replace parts of a list:

ReplacePart[{a,b,c,d,e,f,g},3->x]

ReplacePart[{a,b,c,d,e,f,g},{3->x,5->y}]

ReplacePart[Characters["The Wolfram Language"],Table[RandomInteger[{1,20}]->"--",5]]

Sometimes one wants particular parts of a list to just disappear. One can do this by replacing them with Nothing.

{1,2,Nothing,4,5,Nothing}

ReplacePart[{a,b,c,d,e,f,g},{1->Nothing,3->Nothing}]

If[StringLength[#]>5,Nothing,StringReverse[#]]&/@RandomSample[WordList[ ],50]

Take takes a specified number of elements in a list based on their position. TakeLargest and TakeSmallest take elements based on their size.

TakeLargest[Range[20],5]

TakeLargestBy and TakeSmallestBy take elements based on applying a function.

TakeLargestBy[Array[RomanNumeral,100],StringLength,5]

Find the last 5 digits in 2^1000. »

Pick out letters 10 through 20 in the alphabet. »

Make a list of the letters at even-numbered positions in the alphabet. »

Make a line plot of the second to last digit in the first 100 powers of 12. »

Join lists of the first 20 squares and cubes, and get the 10 smallest elements of the combined list. »

Find the positions of the word “software” in the Wikipedia entry for “computers”. »

Make a histogram of where the letter “e” occurs in the words in WordList[ ]. »

Make a list of the first 100 cubes, with every one whose position is a square replaced by Red. »

Make a list of the first 100 primes, dropping ones whose first digit is less than 5. »

Make a grid starting with Range[10], then at each of 9 steps randomly removing another element. »

Find the longest 10 words in WordList[ ]. »

Find the 5 longest integer names for integers up to 100. »

Find the 5 English names for integers up to 100 that have the largest number of “e”s in them. »

How does one read list[[n]] out loud?

Usually “list part n” or “list sub n”. The second form (with “sub” short for “subscript”) comes from thinking about math and extracting components of vectors.

What happens if one asks for a part of a list that doesn’t exist?

One gets a message, and the original computation is returned undone.

Can I just get the first position at which something appears in a list?

Yes. Use FirstPosition.

Tech Notes