Megalomania
Member
I need help...
I do a bit of python scripting. I'm getting relatively good at it... although I don't do any strict teachings... I just pick up knowledge around the place...
I have a big problem though.
Here is a basic script outlining what I have.
As all python users should see, the first print will say "You found a bird!"
And the second one (logically) should say "You caught the bird!"
However, Python is less logical than us, so it says
"You found a bird!"
"You caught the ferret!"
As the new string for 'animal' is defined locally in the fuction 'bird'.
How do I fix this so the variable carries over different functions?
Any help is appreciated.
I do a bit of python scripting. I'm getting relatively good at it... although I don't do any strict teachings... I just pick up knowledge around the place...
I have a big problem though.
Here is a basic script outlining what I have.
Code:
animal = "ferret"
#--------------------
def bird(n):
animal = "bird"
print "You found a", animal, "!"
catch(1)
def catch(n):
print "You caught the", animal, "!"
#--------------------
bird(1)
As all python users should see, the first print will say "You found a bird!"
And the second one (logically) should say "You caught the bird!"
However, Python is less logical than us, so it says
"You found a bird!"
"You caught the ferret!"
As the new string for 'animal' is defined locally in the fuction 'bird'.
How do I fix this so the variable carries over different functions?
Any help is appreciated.