list
Ініціалізація
empty_list = []
empty_list = list()
int_list = [11, 19, 21, 29, 46]
sevens_list = ['7'] * 7
ordered_list = [i for i in range(10)] # [0, 1, 2 ... 9]
# конструктор range() має дві форми визначення:
# range(stop) та range(start, stop[, step])
mylist = ["apple", "banana", "cherry"] # ['apple', 'banana', 'cherry']
print(mylist)
print(type(mylist))
mylist = [1, 3, 5] # [1, 3, 5]
print(mylist)
print(type(mylist))
# mylist = list(1, 3, 5) # ERROR!
mylist = list((1, 3, 5)) # !!! [1, 3, 5]
print(mylist)
print(type(mylist))
mylist = [] # []
print(mylist)
print(type(mylist))
mylist = list() # []
print(mylist)
print(type(mylist))
mylist = list("abra") # !!! ['a', 'b', 'r', 'a']
print(mylist)
print(type(mylist))
mylist = list(("abra")) # !!! ['a', 'b', 'r', 'a']
print(mylist)
print(type(mylist))
mylist = list(("abra",)) # !!! ['abra']
print(mylist)
print(type(mylist))
Last updated