Passing a variable between Python functions -


i new python , coding , trying figure out how pass result of 1 function calling function variable passed can used within calling function.

in code below, error states that:

global name 'quiz' not defined.

my intent pass string printed based upon user input.

difficulty = raw_input("please enter level of difficulty: easy, medium, or hard: ")  def test_method(difficulty):   if difficulty == 'easy':     quiz = "yup - quiz me"   else:     quiz = "nope - yikes!"   return quiz 

i've tried using print quiz here , expected string prints. pass quiz variable calling function , print result there.

def test_call(difficulty):   test_method(difficulty)   print quiz  test_call(difficulty) 

just assign , / or return quiz

def test_call(difficulty):     quiz = test_method(difficulty)     print quiz     return quiz 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -