0

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')
Adam Smith
  • 52,157
  • 12
  • 73
  • 112

3 Answers3

0

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()
Avad
  • 197
  • 1
  • 8
0

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!

smbrine
  • 1
  • 2
  • Got it mate! Thanks so much. Sorry, im really new at this and I'm very interested in learning it. I dont have much any background in programming. Glad I found this community. – Jim Russ Feb 18 '23 at 08:48
0

it's possible that the output isn't displaying because you're not calling the function.

def greet():
    print('hi')

# Call the function
greet()
buran
  • 13,682
  • 10
  • 36
  • 61