Complete the following exercises by editing this file directly on GitHub, using the little pen symbol at the top right of the text box on this page.
Use the Python interpreter to confirm your answers as you go. After writing each answer, make a commit by scrolling down, writing a commit message, and pressing the green button.
Use the following list for the questions:
my_list = [1, 2, "kitten", 4, "five"]
Note that the little quote marks you see around this line when editing make it look like code on the original page! Use them for your answers when the answer is code.
- Your answer here (remember to commit after editing this line to contain your answer!)
- Your answer here (remember to commit after editing this line to contain your answer!)
- Your answer here (remember to commit after editing this line to contain your answer!)
(HINT: Look up the len method for Python lists.)
- Your answer here (remember to commit after editing this line to contain your answer!)
- Your answer here (remember to commit after editing this line to contain your answer!)
my_list = [1, 2, “kitten”, 4, “five”, 6, 7]
access method | value |
---|---|
my_list[0] | 1 |
my_list[1:3] | |
my_list[1:6] | |
my_list[1:10] | |
my_list[-1] | |
my_list[-1:-3] | |
my_list[-3:-1] |
(remember to commit after editing this table to contain your answer, and removing this line!)
Now call over one of the instructors or the TA to come look through your commit history!
Once they have, go back to the main page of the repository by clicking the hackbright-intro-lists-and-io
link at the top of the page.