-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask1.py
More file actions
38 lines (31 loc) · 982 Bytes
/
Task1.py
File metadata and controls
38 lines (31 loc) · 982 Bytes
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
"""
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
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)
"""
TASK 1:
How many different telephone numbers are there in the records?
Print a message:
"There are <count> different telephone numbers in the records."
"""
def unique_phone_count(calls):
combined = set()
for call in calls:
outgoing_calls, incoming_calls = call[0], call[1]
combined.add(outgoing_calls)
combined.add(incoming_calls)
for text in texts:
outgoing_texts, incoming_texts = text[0], text[1]
combined.add(outgoing_texts)
combined.add(incoming_texts)
return len(combined)
unique_phone_count(calls) # 570
count = unique_phone_count(calls)
print('There are', count, 'different telephone numbers in the records.')