Reputation: 11
So I'm trying to make a function that can be called with a few simple parameters to simplify and streamline my madlibs game, and I'm sorting my code in sections using this trick:
(#) section name
integer = 420
string = ("random crap")
It's great since it allows me to quickly and easily fold away sections I don't need clogging up my screen (also just in general I work slower and feel more overwhelmed when my entire screen is just covered top-to-bottom in code, even if I'm only working on one small section of it), but for some reason if there's a function in one, the line the function is defined is underlined red and the code fails to start, but more importantly and confusingly, if I do it twice, the only one that breaks is the very first one, giving me the same "[pyflakes] invalid syntax" error without underlining/marking errors for any other one:
(#) foldable section
def thisOneBreaksForSomeReason (andIsUnderlinedRed):
print ("I have no idea why")
(#) another foldable section
def whileThisOneIsCompletelyFine (withNoDetectedErrors):
print ("This doesn't make any sense")
I just don't get it, and I don't know if there's just something I'm missing about how python/functions work, or if I'm just using a bad method to section my code that may break other stuff down the line too. Does anyone have any insight as to why this is, and if the method I'm using for sectioning code is bad, or if the way I define that function is bad? The problem probably has to do with only one of them, I just don't know which. Also I don't know if this is relevent but I'm using replit as my IDE in case that matters/could also have to do with my issue.
Thank you!
Upvotes: 1
Views: 37
Reputation: 108
The syntax is wrong, here it is cleaned up. The functions are callable and they do their thing.
import time
# section name
integer = 420
string = "random crap"
# foldable section
def thisOneBreaksForSomeReason ():
print ("I have no idea why")
# another foldable section
def whileThisOneIsCompletelyFine ():
print ("This doesn't make any sense")
thisOneBreaksForSomeReason()
time.sleep(2)
whileThisOneIsCompletelyFine()
Upvotes: 1