立即学习:https://edu.csdn.net/course/play/26676/338778?utm_source=blogtoedu
lst = [1,2,3,4]
lst[2] = 300
lst now is [1,2,300,4]
element in list can be changed
lst.qppend("python)
now lst is [1,2,300,4,'python']
it doesn't create a new list
lst.insert(0,10)
now lst is [10,1,2,300,.....]
lst2 = ['a','b']
lst.extend(lst2)
now a b are at the end of lst
also if extend a word eg. book
it will become 'b', 'o','o','k'
lst.pop() means delete the last element and show it in the outcome
lst.remove('b')
romeve one b in the list
lst.clear() clear the whole list
but!!!! is use eg, a = [1,2,3]
a =[ ]
this bulids a new a, different with the method clear above
use sort to sort it from small to large
is want the reverse, use sort(severse = Ture)
or it can be lst[::-1]
s= "python"
lst = list(s)
lst now is ['p','y','t'.......]
then
"".join(lst) gives 'python'
can not use str(lst)
or it will be "['p','y','t'......]"