You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
programming-basics-2022/01/list.py

47 lines
621 B

a = ["one", "two", "three"]
a[2] + " people"
"three people"
a + [2, 3]
["one", "two", "three", 2, 3]
a.append(True)
print(a)
["one", "two", "three", True]
a.extend([4])
a
["one", "two", "three", True, 4]
a.insert(0, "zero") # Почему плохо?
a
["zero", "one", "two", "three", True, 4]
a = ["one", "two", "three", "for"]
a[1:3:2]
["two"]
a[::2]
["one", "three"]
a[0:2] = []
a
["three", "for"]
a = ["one", "two", "three", "for"]
a.remove(152)
# ValueError Traceback (most recent call last) ----> 1 a.remove(152)
# ValueError: list.remove(x): x not in list
a.index("one")
0
"two" in a
True
len(a)
4