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
8 ответов
+ 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.
+ 6
Please, give detailed description of task and what you want to achieve
+ 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
+ 2
Emerson Prado thanks for the reply.
https://code.sololearn.com/c189uDQBdJAE/?ref=app <— heres the code.
+ 1
تاريخ الانضمام Do not spam here
0
Keep getting the error that theres a indentation error
0
Think i fixed all identations, still getting same error
0
Thank you D Shah 🎯⏳️ Emerson Prado