'Can't figure out logic for this assignment

school_days = 15
classes_per_day = 5
total_classes = 75
for counter in range(school_days):
    total_classes = total_classes + classes_per_day

print(total_classes)

Here are the instructions in the assignment:

Task - Change the values stored in the variables school_days, classes_per_day, and total_classes so that the loop calculates the classes for a student that has 15 school days left. The student has 5 classes per day. The final value of total classes should be 75.

Output: 75

I've been trying to figure this out for the last hour, and I don't know what I'm doing wrong.



Solution 1:[1]

I don't know exactly what you are trying to achieve but you could try this:

school_days = 1
classes_per_day = 0
total_classes = 0
total_classes = total_classes + classes_per_day
for counter in range(school_days):
    print(total_classes + 1)

Solution 2:[2]

There is no syntax error try changing the zeros to values like

school_days = 10
classes_per_day = 4

Solution 3:[3]

There is no syntax error (which is an error that forbids to run the code by the way) but nothing can happen with zeros

You may set 15 and 5 but not total_classes that will contain the result

school_days = 15
classes_per_day = 5
total_classes = 0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BRAMtheBEGINER
Solution 2 Yousif Gad
Solution 3