Ask coding questions

← Back to all posts
I need help
johnnyfrancis (24)

So In The program below I tried to make a way to make a coding editor like repl. But on line 46 in file It.py All the if statments dont work. Can Someone tell me whats wrong? Thank you!

Answered by ChopSueyMaster (49) [earned 5 cycles]
View Answer
Comments
hotnewtop
ChopSueyMaster (49)

This is because you are saying if "newline" only, not that if write == "newline"
so redacted:

if write == "NEWLINE" or write == "Newline" or write ==  "newline":
    f.write("\n")
johnnyfrancis (24)

@ChopSueyMaster Ohhh. Ok and i just checked my code and lol i forgot to stop the "'s before wrtiting or. Thx!

InvisibleOne (2990)

Here's your problem, you can't put or and then not put the operator, so line 46 needs to be
if write == 'NEWLINE or Newline" or write == "newline":
However, this is unnecessary since you can shorten that whole line to this if write.lower() == 'newline': which lowers all the text.

johnnyfrancis (24)

Thx. I wish it was possible to make there be 2 answers. If it was I would select yours as answer thx. Ima check out your projects.

InvisibleOne (2990)

I don't care if you select mine as the answer, I'm just saying using .lower() and then only checking for a single value is much better then checking all three. @johnnyfrancis

IMayBeMe (484)

It says that you don’t have a env key names secret, try checkin your env tab

johnnyfrancis (24)

@IMayBeMe Ok I checked the tab it says i do.