user3453542
user3453542

Reputation: 11

Can't define functions in Python

Whenever I write a function and then run it in the Shell, it comes up blank. I have only been programming for about a month so don't make things very difficult.

My code looks like this:

def intro():

   print("hello world")

Then when I run it, it . No air message pops up. Except in my code the 2 lines are touching

Upvotes: 1

Views: 3398

Answers (2)

Alexander
Alexander

Reputation: 4219

You need to call your function! Do this with intro() after the function is defined (Hugh has a nice example above my answer). Better read up on some basics first ;) Codeacademy has an awesome Python course if you're interested.

Upvotes: 0

Hugh Bothwell
Hugh Bothwell

Reputation: 56654

You wrote a function; now you have to tell it to run the function!

Try

def intro():                # <= this tells Python what "intro" means
    print("hello, world")

intro()                     # <= this tells Python to actually do it

Upvotes: 6

Related Questions