Chocolate 50 Biscuit 35 Ice cream 50 Rice 100 Chicken 250 (blank line in b/w) Perfume Free Soup Free (blank line in b/w) Discount 80
If this is the content of file, I've to iterate through, calculate the total spending and count in the discount as well and calculate the final bill amount; how to do that?
Till now I've tried this,
path=input("Enter the file name:")
listOfLines = list()
with open (path, "r") as myfile:
for line in myfile:
listOfLines.append(line.strip())
Here listOfLines will show the contents as list items, but i don't know what to do next?