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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -