1

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

2
  • 1
    How are you invoking the function? Commented Mar 23, 2014 at 23:33
  • 1
    Can you write how you call it from the shell? are you defining it in a file (for example example.py) and then importing it? Commented Mar 23, 2014 at 23:33

2 Answers 2

6

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
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.