-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.py
22 lines (15 loc) · 911 Bytes
/
process.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
""" Open file 'um-server-01.txt' and print the lines with Sales
information for Tuesday."""
log_file = open("um-server-01.txt") # Open file 'um-server-01.txt'
def sales_reports(log_file): # Accept file handle(?) as argument
for line in log_file: # Loop through each line on the file
line = line.rstrip() # Strip spaces to the right
day = line[0:3] # Get the day by extracting the first
# three characters of the string
# Original Code - If it equals Tue, then print the line
# Updated to instead check for 'Mon' and print the line
#if day == "Tue":
if day == "Mon":
print(line)
# Call the function 'sales_reports' passing the file objecrt as the argument
sales_reports(log_file)