-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask1.py
43 lines (36 loc) · 1.12 KB
/
Task1.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
"""
Read file into texts and calls.
It's ok if you don't understand how to read files
You will learn more about reading files in future lesson
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
creast blank list and add iterable the number into the list.
divide into text and calls separately.
"""
telnumber_text = []
for text in texts:
if text[0] not in telnumber_text:
telnumber_text.append(text[0])
if text[1] not in telnumber_text:
telnumber_text.append(text[1])
telnumber_call = []
for call in calls:
if call[0] not in telnumber_call:
telnumber_call.append(call[0])
if call[1] not in telnumber_call:
telnumber_call.append(call[1])
total_numbers = list(set(telnumber_call+ telnumber_text)) # make set to delete duplicate numbers.
print("there are {} different telephone numbers in the records.".format(len(total_numbers)))
"""
TASK 1:
How many different telephone numbers are there in the records?
Print a message:
"There are <count> different telephone numbers in the records."
"""