The array in Python is also called list, and there is a tuple called. The list is also a regular usage, such as creating an array and writing the contents to it as follows:
arrlist=["Tom", "Jerry", "Dog"
It is noteworthy that the parentheses of the array are "[" instead of curly braces, and C # is not the same, being pits a little below. And for the array list, his requirements for the content of 1 is very flexible, such as can contain characters, strings, shaping, floating point number, or even another array, such as arrlist=["a", 1.2,["B", 1], if we want to take a word directly with arrlist[0], If we want to get a B, this is how to write arrlist[2][0], this is a two-dimensional array, any computer learns that the array starts from 0. This is self-evident.
In summary, the list in Python is very flexible.
The Python array, in addition to the list, has a tuple array, which, like constants, cannot be changed once defined, such as defining a tuple type array arrlist= (1. "). A "," AC "), you can see that the tuple type array is defined by a parenthesis, and the list is defined in brackets. Very well differentiated. Depending on the tuple's content, it is easy to know that the scenario used is a high-level consideration for system security.
Say a few of the commonly used methods of list and tuple Len (arrlist), needless to know, get the length of the array. Arrlist.append ("str") appends an element to the end of the array, and if you want to add an element after the specified position, such as adding "s" to the 2nd bit, you can Arrlist.insert (2, "s"), The Pop (i) method Arrlist.pop (i) can be used if you want to remove elements that touch a position. Python also has a more useful place is that if you want to get the last element of an array, but do not know its actual length you can write Arrlist (-1), the penultimate is-2, very useful.
Finally, note that if the array has only one element, the definition must be added with a "," comma has been eliminated. such as arrlist= (1,).
Condition Judgment:
Very simple, if condition:
Do some things,
Else
Do something else,
If there are multiple conditions, write it like this:
If condition:
Do some things,
Elif Conditions:
Do some things,
Else
Do some other things
Python Learning Diary-arrays and if judgments