-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.py
86 lines (61 loc) · 1.49 KB
/
list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def main():
list1 = [1, True, 'Dog']
print(list1)
print(len(list1))
list1.append(2.5+5.9j)
print(list1)
list1.extend([96, 97, 98])
print(list1)
print(list1 + [3, 4, 5])
print(list1)
print([1, 2, 3] * 3)
print(list1 * 3)
print(list1[4])
print(list1[-1])
list1[1] = False
print(list1)
print(list1[2:5])
list1[0:2] = [1, 2, 3, 4, 5]
print(list1)
print(len(list1))
list1.insert(2, 'New_element')
print(list1)
del list1[5]
print(list1)
numbers = [1, 7, 2, 9, 5, 19, 22, 3]
#numbers.sort()
numbers.reverse()
print(numbers)
text = "My new car"
print(text[0])
print(text[0:2])
print(len(text))
print('First row\nSecond row')
print(r'First row\nSecond row')
variable = 5
text1 = f'Variable value is {variable}'
print(text1)
manyRows = """First row
Second row
Third Row"""
print(manyRows)
print('a' < 'b')
text2 = 'my new car'
print(text2.upper())
text3 = 'My New Car'
print(text3.lower())
text4 = ' \n\t Dog \n '
print(text4.strip())
text5 = 'A word, another word, and another word'
print(text5.count('word'))
text5 = text5.replace('word', 'cat')
print(text5)
listOfWords = ['my', 'new', 'car']
print(listOfWords)
print(len(listOfWords))
print(" ".join(listOfWords))
print(len(listOfWords))
text6 = 'My new car'
print(text6.split(" "))
if __name__ == "__main__":
main()