0
Pondering about line 4
import time def after(seconds, func): time.sleep(seconds) func() is line no 4 referring " return func()" ??
7 Antworten
+ 6
In your function, you have 2 parameters - one to select how long the program should pause for and the other that indicates a certain function from the program. What the function will do is wait a short while (depending on what the first parameter is) and then run the function specified by the second parameter. As you're just running the function, you therefore don't need to return it.
+ 2
There is some problems with your indentation, that'll raise an exception
+ 2
No,
you don't need to indicate a function is function.
You put () to execute it
0
so here i am putting the () next to func parameter at line 4 to indicate that second parameter is gonna be a function, it that right ?
0
import time
def after(seconds, func):
time.sleep(seconds)
func()
def hello():
print("Hello World")
after(5, hello)
Output: after 5 seconds
Hello World
# pls explain in details
0
Understood.
Thanks