0

How to use more than one counter in Python

Hey guys trying to solve the python question below and ran into a hitch. I decided to use counters to count the number of bottles but when it came to the crate counter I'm not sure how to modify it. I started off by removing every 15th soda then use modulus to track the 12th soda because every crate consists of twelve. The problem is now how to initialize a crate counter and make it stop once it reaches 999. Help appreciated QUESTION: Charo is a broker who recently found a company that wants to develop a software that counts sodas to be packed in a crate of 12. The company wants the software to count all the sodas produced daily and discard every 15th soda because the machine is faulty and keeps breaking down. CODE: soda=0 crate=0 for soda in range (1001): if soda %2 !=0: print(soda)

1st Aug 2020, 1:45 PM
sockamine
sockamine - avatar
2 Answers
0
You don't need a single loop for that task... You can work purely with mathematics (division, subtracting, adding...).
1st Aug 2020, 2:34 PM
Sandra Meyer
Sandra Meyer - avatar
0
Though, if you want a second counter, just increase our decrease it within your loop. You might change it to a while loop for such cases then (e.g. while number < max).
1st Aug 2020, 2:36 PM
Sandra Meyer
Sandra Meyer - avatar