CS 110 Lecture Notes - Lecture 11: Mutator Method

48 views2 pages
20 Oct 2016
Course
Professor

Document Summary

Other languages call this an array, but python calls it a list. This creates an empty list. mylist2 = [ chocolate , vanilla , strawberry ] mylist3 = [10,20,30, chocolate , vanilla ] Concatenates the two lists and prints them. Literal: a value that is not stored in a variable. In the above example, [1,2] and [3,4] are literals, because they are used without being stored in a variable. It is possible to have a list of lists (of lists of lists ) del(mylist3) completely deletes the list. You should avoid changing a list while looping through it, to avoid index issues. Aliasing: giving a new name to the same object list1 = [1,2,3] list2 = list1 list2 is just an alias that refers to the same object. If you change the list in list1, it will change list2 as well, because they refer to the same list object.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents