I'm a newbie in python I'm trying to use def function and every time I run the code it gives me a blank output. I'm using pyroid3 in my phone since I dont have any laptop/desktop.
I'm trying to get thru with this code
def greet():
print('hi')
I'm a newbie in python I'm trying to use def function and every time I run the code it gives me a blank output. I'm using pyroid3 in my phone since I dont have any laptop/desktop.
I'm trying to get thru with this code
def greet():
print('hi')
You have to call your function. With def
you only declare it.
In python we calling function by adding ()
.
Like this:
def greet():
print('Hello')
greet()
I apologize if it is an obvious question but have you tried to call your function? For example try to add greet()
at the end of your code. It will look like this:
def greet():
print('hi')
greet()
Feel free to ask if you need explaination!
it's possible that the output isn't displaying because you're not calling the function.
def greet():
print('hi')
# Call the function
greet()