python
Create a function in python
def function_name():
print("Hello this is a function")
#To call the above function use
function_name()
Output
Hello this is a function
You can create a function in python by using the 'def' keyword before the function name. The above code snippet function will print - Hello this is a function when called. You can also use the function to return some values or data when called.
Was this helpful?
Similar Posts
- [Python] Range - standard function to create a list of numbers
- Function argument unpacking in Python
- [Python] Function returns multiple values
- [Python] Function parameters - pack and unpack
- [Python] Eval() function
- [Python] Get nodeid, module, function name using Pytest request built-in fixture
- [Python] Default value of function argument