0
Cell Growth bugged?
I cannot get the Cell Growth practice under Python to work for me. I’ve even copied what a number of ppl on here have said is the correct code but it always errors saying the indentation is incorrect. Im on mobile so the longer code for line 14 has to use a 2nd line to fit it all (incomplete example below) print("Day " + str(counter) + ": " +str(cells)) The +str(cells)) is the part that goes to the next line. In any case, is there a way to complete this on mobile? Also as an added question, can anyone break down the logic behind this code? I understand the math and all but I’m not understanding how this code (or rather the correct code to this problem) solves the question.
3 Antworten
+ 4
if you are coding a long line of text, you can just type it all in one line and let the editor wrap the displayed text. Don't press the enter key unless you are sure it's the right part to break the statement.
there are rules where you can break a line of code into two or more lines, and some of them are language-specific.
for your example, you can break it like
print( "Day " + str(counter) +
": " + str(cells))
but not break a string in the middle like this
print("Day " + str(counter) + "
: " + str(cells))
you have to escape the string break with a "\"
print("Day " + str(counter) + "\
: " + str(cells))
it's a bit complicated if you're a beginner, so just type your long line of code and let the code editor wrap it.
https://stackoverflow.com/questions/53162/how-can-i-do-a-line-break-line-continuation-in-JUMP_LINK__&&__python__&&__JUMP_LINK-split-up-a-long-line-of
also be careful of invisible characters and backticks when copy-pasting. the code might look ok, but it's not.
https://peps.python.org/pep-0008/
+ 2
There can be no error in this line, show the full code.
+ 2
If you copied from here:
https://www.sololearn.com/Discuss/3314629/?ref=app
You have to read that the code needs to be modified. And be mindful that codes copied from the forum often have some kind of format error - you'd be better off copying it by writing it out from the source.
It really helps if you add your code as per this guide (you might have to copy and paste to create it):
https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app