0
Ideally function shouldn't be lengthy, but if multiple task require same inputs from users, is it okay to hv lengthy function?
3 Respostas
+ 6
you can keep passing the same input through the functions I guess. here's a silly example:
info=input()
def doThing(info):
return str(info)
def doOtherThing(info):
print(info)
info=doThing(info)
doOtherThing(info)
Edit: if you got a bunch of notifications, there was a troll/spammer here that I got in a conversation with. They are gone now and I deleted everything.
+ 3
Beside what Ahri Fox said, its ok have lengthy functions while they are not composed by codes that can be modularized (eg. they can be used outside function context) else its better (eg its not mandatory but help) create multiple functions
P.S. @Ahri Fox Thank you 😉
+ 1
Sometimes when you have a lengthy function, you can delegate further and call other functions from within, using the original arguments.