Reference (Reference)
Do not know why not translated into a reference.
shoplist = [
‘apple‘
,
‘mango‘
,
‘carrot‘
,
‘banana‘
]
mylist = shoplist
In this case, MyList and Shoplist point to the same memory space. So what if you want to copy exactly one copy instead of quoting Shoplist?
MyList = shoplist[:]
Complete example
slicing (Slice)
Yesterday suddenly noticed the sequence of slices in front and back. Try it out, if it's a range of [3:2], then output an empty list. Of course [2:-1] This is no problem, 1 is meant to be the last.
The section of the slice is actually [), that is, before closing.
A fast online interpreter.
Default parameters
Only those parameters at the end of the formal parameter list can have default parameter values-that is, you cannot declare a formal parameter with a default value and then declare a formal parameter that has no default value when declaring a function parameter.
This is because the value assigned to the parameter is assigned according to the position. For example, def func(a, b=5)
it is valid, but def func(a=5, b)
it is not valid .
Key parameters
Advantage -one, since we don't have to worry about the order of the parameters, it's easier to use the function. Second, assuming that the other parameters have default values, we can only assign values to the parameters we want.
Concise Python Tutorial Learning Notes