I currently have a variable in one of my functions. A separate function after it utilizes the variable but cannot seem to use it and creates a syntax error. Is it possible to store a variable inside of a function?
Can I store a variable inside of a function?
Collapse
X
-
Tags: None
-
My code is a bit long so I'll sum it up here.
Code:def weapon(): weapon = raw_input("What weapon would you like?") def forest_troll(): return "You stroke out with your " + weapon + "." weapon(x) forest_troll()
Also, the spaces/indents didnt show up sorryComment
-
Return the weapon selection in function weapon() similar to:
Code:>>> def weapon(): ... return raw_input("What weapon would you like?") ... >>> def forest_troll(w): ... return "You stroke out with your " + w + "." ... >>> forest_troll(weapon()) 'You stroke out with your Knife.' >>>
Comment
-
Return the weapon selection in function weapon() similar to:
Code:>>> def weapon(): ... return raw_input("What weapon would you like?") ... >>> def forest_troll(w): ... return "You stroke out with your " + w + "." ... >>> forest_troll(weapon()) 'You stroke out with your Knife.' >>>
Comment
Comment