+ 1
why use a funcion?
3 Answers
+ 1
I've gathered that functions could act as a shortcut for repeating a code. Example:
def my_func():
print('I can')
print('print all this')
print('with just my_func()!')
So you could print all those lines with just using "my_func()". I believe this is what you were asking.
0
thanks
0
Functions can be used to group together commonly used tasks. For instance, you can create a function that opens a file, closes it and returns the data so that you only ever have to call that function when you need something.