3. Boolean and List

Boolean 
false false 0
to true True 1

List
[] empty list
names = [ "Xingxing", "Xiaojia", "Xiaoming", "Zhao", "SB"]
type (names) type <class list>
the subscripts stored and value name [1] = "xiaojia"

by
inserting
names = [ "Xingxing", "Xiaojia", "Xiaoming", "Zhao", "SB"]
names.insert (. 3, "LAN")

is added
names.append () appending
the number of elements

names.count ( "sb") sb number of

puncturing
del names [1]

to change
names [-1] = "xiangsihan"

check
"xiangheng" in names

check deleted with
del names [names.index ( "SB")]
index () to find the corresponding element of the index, and returns the index, del delete

names.index () element index
names.pop () to delete the last value and return value to be deleted
names.extend () to expand
names.reverse () reverse
names.sort () to sort

Guess you like

Origin www.cnblogs.com/xh716/p/11546919.html