Check for correctness of calories format

This commit is contained in:
ziadarafat committed 2022-10-18 13:51:04 -06:00
1 parent 8a3cbd1786
commit 5fccb2e78c
1 file changed
+5 -1
+5 -1
View File
@@ -38,10 +38,14 @@ if __name__ == "__main__":
line_count = 0
for row in csv_reader:
if line_count == 0:
if len(row) not in (1, 8):
print("Your calories line does not meet the correct format.")
exit()
max_calories = extract_calories(row)
line_count += 1
else:
if "#" not in row[0]:
calories_in_plan += int(row[1]) * calorie_dict[row[0]]
print("Calories:", calories_in_plan)
print("Calories Allowed Today:", max_calories)
print("Calories In Plan:", calories_in_plan)
print("Excess calories: ", calories_in_plan - max_calories)