-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex32.py
34 lines (26 loc) · 877 Bytes
/
ex32.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
the_count = [1, 2, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'peenies', 2, 'dimes', 3, 'quartesrs']
#The first kind of for-loops goes through a list
for number in the_count:
print(f'This count {the_count}')
# Same as above
for fruit in fruits:
print("a fruit of type: {}".format(fruits))
#We can go throught mixed lists too
#Notice we have to use {} since we dont know whats in it
for i in change:
print("I got {}".format(i))
#we can also build lists, first start with an emply on
for i in range(0,6):
print(i)
elements = []
#elements[:] = range(5)
#then use the range function to do 0 to 5 counts.
elements.append(1)
#elements.insert(3,8)
#elements.extend([87,34,65])
print("This is new elemtns: {}".format(elements))
#We can print them too
for i in elements:
print("elemetns become: {}".format(i))