# EMI Exercise Problem

Hello Folks,
I have created different functions for the exercise problem of EMI calculation but I am not getting how
to combine these all functions to get a single function to form a dictionary …

``````def readlines(path):
with open(path, 'r') as f:
return lines
``````
``````def parse_values(data_line):
result = []
for item in data_line.strip().split(','):
if item == '':
result.append(0.00)
else:
result.append(float(item))
return result
``````
``````def list_of_parameter(parameters): # Parameter will be number like 1, 2, 3 to get list of amount, rate of intrest, down payment etc.
lists = []
for data_line in lines[1:]:
values_in_data_line = parse_values(data_line)
lists.append(values_in_data_line[parameters])
return lists
``````
``````def all_list(no_of_column):
final_list = []
for i in range(0, no_of_column):
single_list = list_of_parameter(i)
final_list.append(single_list)
return final_list
``````
``````def parse_headers(header_line):
``````
``````def parse_headers(header_line):

def parse_values(file_lines):
lines = []
for file_line in file_lines[1:]:
line = file_line.strip().split(',')
lines.append(line)
return lines

lines_list = []
i = 0
lst = []
for line in list_of_values:
if line[i] == '':
lst.append(0.0)
else:
try:
lst.append(float(line[i]))
except ValueError:
lst.append(line[i])
lines_list.append(lst)
i = i + 1
return lines_list

result = {}
return result

# open the file in read mode
with open(path, 'r') as f:
# Get a list of lines
# parse the remaining lines
values = parse_values(lines)
# putting values of commomn header under a list
# Create a dictionary using values & headers
return result``````
2 Likes

UnsupportedOperation Traceback (most recent call last)
/tmp/ipykernel_63/4215172479.py in