1#Creating lists
2my_list = ['foo', 4, 5, 'bar', 0.4]
3my_nested_list = ['foobar', ['baz', 'qux'], [0]]
4
5#Accessing list values
6my_list[2] # 5
7my_list[-1] # 0.4
8my_list[:2] # ['foo', 4, 5]
9my_nested_list[2] # ['baz', 'quz']
10my_nested_list[-1] # [0]
11my_nested_list[1][1] # 'qux'
12
13#Modifying lists
14my_list.append(x) # append x to end of list
15my_list.extend(iterable) # append all elements of iterable to list
16my_list.insert(i, x) # insert x at index i
17my_list.remove(x) # remove first occurance of x from list
18my_list.pop([i]) # pop element at index i (defaults to end of list)
19my_list.clear() # delete all elements from the list
20my_list.index(x[, start[, end]]) # return index of element x
21my_list.count(x) # return number of occurances of x in list
22my_list.reverse() # reverse elements of list in-place (no return)
23my_list.sort(key=None, reverse=False) # sort list in-place
24my_list.copy() # return a shallow copy of the list
1myList = ["Test", 419]
2myList.append(10)
3myList.append("my code")
4print(myList)
1>>> # this example show how to retrieve elements of a sequence
2>>> "ABCD"[0]
3'A'
4>>> [0, 1, 2][1]
51
6>>> ("ABC", "DEF", "GHI")[1]
7'DEF'
8
1# a great programming language emphasizing readibility and easy syntax words.
2
3print("Hello World!")
1Python is a super easy, interpreted, high-level and general-purpose programming
2language