0

Help with practice exercise

Want to run this code from a practice question, but can’t seem to run it # take the initial cell population as input cells = int(input()) # take the number of days as input days = int(input()) # initialize the day counter counter = 1 #complete the while loop while counter < days +1: cells = cells*2 # Daily message print("Day " + str(counter) + ": " +str(cells)) counter = counter + 1

14th Jun 2023, 2:34 AM
Ronal Castro
8 odpowiedzi
+ 5
Ronal Castro Yes, there is. The print doesn't have indentation, so it's outside the loop, then will only run when the loop exits. But the lack of indentation makes the counter increment fall outside the loop, so the loop never exits. BTW, instead of pasting the code, save it in Code Playground as public, then add a link to your code in the question description - use "+" button. It's way better to visualize, allows testing and avoids copy errors.
14th Jun 2023, 3:07 AM
Emerson Prado
Emerson Prado - avatar
+ 6
Please, give detailed description of task and what you want to achieve
14th Jun 2023, 2:46 AM
D Shah 🎯⏳️
D Shah 🎯⏳️ - avatar
+ 4
Your line 16 is incorrect after print() statement, instead it is supposed to be after while loop. i.e., after line 12 try to fix it again
14th Jun 2023, 3:52 AM
D Shah 🎯⏳️
D Shah 🎯⏳️ - avatar
+ 2
Emerson Prado thanks for the reply. https://code.sololearn.com/c189uDQBdJAE/?ref=app <— heres the code.
14th Jun 2023, 3:26 AM
Ronal Castro
+ 1
15th Jun 2023, 9:33 AM
Emerson Prado
Emerson Prado - avatar
0
Keep getting the error that theres a indentation error
14th Jun 2023, 2:53 AM
Ronal Castro
0
Think i fixed all identations, still getting same error
14th Jun 2023, 3:49 AM
Ronal Castro
14th Jun 2023, 4:05 AM
Ronal Castro