Problem with function in python -


i newbie in python. trying code basic function getting errors. dont know reason behind it. example code:

def printme( str ):     print str;     return;  printme("my string"); 

this should execute logically gives me following error:

traceback (most recent call last): file "stdin", line 1, in "module"
nameerror: name 'printme' not defined

any suggestions welcome...

the semicolons shouldn't there return statement (the execution of function ends @ last statement indented within it).

not entirely sure how formated indent python relies on determine scope

def printme(str):     print str #this line indented,                #that shows python instruction in printme  printme("my string") #this line not indented.                       #printme's definition ends before 

executes currectly

wikipedia's page on python syntax covers indentation rules.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -