Here is the entire question I am trying to solve:
Implement a function getCustomerList that takes as argument filename to read the file and return it as a nested list, where each element is a list of [, <Clerk’s Desk>, ]. The filename argument doesn’t contain the extension (i.e. “input”), your program must automatically add the “.txt” extension. If the file doesn’t exist, the getCustomerList function will print the message: “Error! not found.”, and should return None.
My Problem: I am having trouble in getting the last item (minutes) to return WITHOUT quotes.
Here are my expected and actual results:
Name, Desk, Minutes
Here is my code:
def getCustomerList(filename):
current_file = filename + ".txt"
data = []
# write code to check if file exist and return List/None
try:
open_file = open(current_file, "r")
for aline in open_file:
values = aline.split(",") # Break each line into a list
lines = [(n.rstrip('\n')) for n in values]
data.append(lines) # Add the row to the list
return data[1:]
print(data)
except IOError:
print("Error! " + current_file + " not found.")