Sunday, August 3, 2014

Day 120

Python at CodeCademy. Worked on Python tutorial 2 of 14, Python Lists and Dictionaries: Access by Index! Learned to access an individual item on a list with its index.

The code used:
numbers = [5, 6, 7, 8]

print "Adding the numbers at indices 0 and 2..."
print numbers[0] + numbers[2]
print "Adding the numbers at indices 1 and 3..."
print numbers[1] + numbers[3]

The interaction for this code:
Adding the numbers at indices 0 and 2...
12
Adding the numbers at indices 1 and 3...
14

No comments:

Post a Comment