WEB DEVELOPER SITE
PHP7
 

Phython List


Python List are very important topics each element are assigned with the assign number position to index .


List Operator Basic

Python Expression Description example
len([1, 2]) Length 2
['Hello worlds!'] * 2 Repetition ['Hello world!','Hellow world!']
[1,2] + [3,4] Concatenation [1,2,3,4 ]
2 in [1,2] Membership true
for a in [1, 2 ]: print a, Iteration 1 2


Python collition are four type such as List,Tuple ,Tuple ,Tuple

In this chapter we read about List

python List

#first example
list1 = ["php", "sql", "php 7.2.5", "sql"]
 print(list1);
Result Answer : ['php', 'sql', 'php 7.2.5', 'sql'] #second example

Change the second item

Example

thislist = ["php 7.2.5 ", "sql", "php"]
thislist[1] = "python"
print(thislist)
Try it yourself »

python list() Constructor

list() constructor to make a list

Example

 thislist = list(("Vegetables", "Fruit", "Grain")) # note the double round-brackets
print(thislist)
Try it yourself »