0
What is def? I can not undestand this code.help me
def my_func(): print("spam") print("spam") print("spam") my_func()
2 Antworten
+ 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.