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
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.