"Python programming from entry to practice" (Chapter IV. Operation List) notes

  1. List for storing digital collection.

  2. List comprehension. squares = [value ** 2 for value in range (1,11)]
    expressed as value ** 2, for providing values to the expression for the loop.

  3. Replication list, create a list that contains the entire slice is while omitting starting index and ending index ([:]).
    . = EG friends_foods my_foods [:]

  4. friends_foods = my_foods, this syntax is actually allow python to associate friends_foods new variable to the list contained in my_foods in, so these two variables point to the same list.

  5. Ganso looks like a list, but the use of parentheses instead of square brackets, its elements can not be modified unless redefine Ganso.

Published 12 original articles · won praise 0 · Views 1892

Guess you like

Origin blog.csdn.net/qq_38122800/article/details/104104421