The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Write a program so that display a count of the number of patients born each year John Hanson, 23 Elm, 1927 Mary Locust, 476 Maple, 1950 Susan Monroe, 512 Peachtree, 1957 Carol Fortune, 2819 Locust, 1960 James Fortune, 2819 Locust, 1963 Lawrence Fish, 12 Elm, 1968 Janice Weiss, 234 Birch, 1971 Henry Garza, 199 Second, 1973 Kimberly Swanson, 310 Appletree, 1980 Louis Claude, 2716 Third, 1981 Jill Fox, 12 Oak, 1985 Opal Reynolds, 78 County Line, 1987 Francis Dumas, 67 Fourth, 1992 Madison Conroy, 23 Fifth, 1996 Daniel Moy, 100 Sunset, 1987
-
The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Write a
program so that display a count of the number of patients born each yearJohn Hanson, 23 Elm, 1927
Mary Locust, 476 Maple, 1950
Susan Monroe, 512 Peachtree, 1957
Carol Fortune, 2819 Locust, 1960
James Fortune, 2819 Locust, 1963
Lawrence Fish, 12 Elm, 1968
Janice Weiss, 234 Birch, 1971
Henry Garza, 199 Second, 1973
Kimberly Swanson, 310 Appletree, 1980
Louis Claude, 2716 Third, 1981
Jill Fox, 12 Oak, 1985
Opal Reynolds, 78 County Line, 1987
Francis Dumas, 67 Fourth, 1992
Madison Conroy, 23 Fifth, 1996
Daniel Moy, 100 Sunset, 1987

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Im still getting an error
![¤
A
PCC
Code File Edit Selection View Go Run Terminal Window Help
RUN AND DEBUG
VARIABLES
✓ Locals
> special variables
> year_count: {}
> Globals
WATCH
CALL STACK
[Errno 2] ...
<module> FE2.1.py
BREAKPOINTS
Raised Excepti...
Uncaught Exce...
User Uncaught ...
ΘΟΔΟ
0
Welcome
FE2.1.py X
Users > ravennreaver > FE2.1.py > ...
1
2
3
4
5
6
19
7
8
9
10
11
12
13
14
15
16
17
D# Dictionary to store the count of patients born each year
year_count = {}
# Read patient records from the file
with open("patient_records.txt", "r") as file:
Process each line (patient record) in the file
for line in file:
# Extract birth year from the record
birth_year
=
Search
int(line.split(", ")[-1].strip())
# Display the count of patients born each year
print("Count of patients born each year:")
for year, count in sorted (year_count.items()):
print (f"{year}: {count} patients")
# Update the count for the birth year in the dictionary
year_count [birth_year] = year_count.get(birth_year, 0) + 1
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL PORTS COMMENTS
/usr/local/bin/python3 /Users/ravennreaver/FE2.1.py
Ⓒravennreaver@Ravenns-MacBook-Air ~ % /usr/local/bin/python3 /Users/rave
nnreaver/FE2.1.py
Traceback (most recent call last):
File "/Users/ravennreaver/FE2.1.py", line 5, in <module>
with open("patient_records.txt", "r") as file:
ΑΛΛΛΛΛΛΑ
FileNotFoundError: [Errno 2] No such file or directory: 'patient_records.txt'
% /usr/local/bin/py
Ⓒravennreaver@Ravenns-MacBook-Air
thon3 /Users/ravenn reaver/FE2.1.py
Traceback (most recent call last):
File "/Users/ravennreaver/FE2.1.py", line 5, in <module>
with open("patient_records.txt", "r") as file:
ID
FileNotFoundError: [Errno 2] No such file or directory: 'patient_records.txt'
O ravennreaver@Ravenns-MacBook-Air ~ % |
Screen Reader Optimized Ln 18, Col 1 Spaces: 4
国
➜•
S
UTF-8 LF
100%
Ơ
80
Wed Dec 6 10:11 AM
the cost of patients are much par
al f
the ch
tv ….. ^
08
Python
Python De...
Python 3.12.0 64-bit ▸tabnine starter →](https://content.bartleby.com/qna-images/question/9d7ccf7d-07aa-4128-bbdb-a47c41a450b8/5ff23b02-f30a-4f88-b0ca-c93d54967ab8/j6t23d8_thumbnail.png)








