0

What is def? I can not undestand this code.help me

def my_func(): print("spam") print("spam") print("spam") my_func()

8th Jul 2020, 5:59 AM
W.D.M.M.S.Karunarathna
W.D.M.M.S.Karunarathna - avatar
2 Réponses
+ 3
def is used to define a function. A function is a piece of reusable code which you can use again and again. Eg, def sayhi(name): print('Hello, '+str(name)) Now, if you want to say hi to someone, then you don't need to write the entire code again, just sayhi('User') In this example, the code was very small, but it can be bigger.
8th Jul 2020, 6:09 AM
Arnesh
Arnesh - avatar