User Profile
Collapse
-
I tried your suggested code but it didn't work for me?... -
My code is a bit long so I'll sum it up here.
it results in a syntax error when i try to pull the value of the variable from the previous function.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 sor...Leave a comment:
-
Can I store a variable inside of a function?
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? -
Thanks guys I redid it and this
# Write your function below!
workedCode:def fizz_count(x): count = 0 for word in x: if word == 'fizz': count +=1 return countLast edited by bvdet; Jun 2 '13, 07:08 PM. Reason: PLEASE use code tags when posting code [code]....[/code]Leave a comment:
-
But shouldn't fizz be in quotes because I'm looking for the word among a list of 'x'. What would expression list be in this case? I'm still a bit confused. And also, is my x input okay right now? I feel like I should make it a list variable but I'm not quite sure how.Leave a comment:
-
Can't Assign to Literal Syntax Error
This is my function. Can anyone help me figure it out?
Code:count = 0 def fizz_count(x): for 'fizz' in fizz_count: int(count) +=1 return countLast edited by bvdet; Jun 2 '13, 03:23 PM. Reason: Please use code tags when posting code [code]....[/code]
No activity results to display
Show More
Leave a comment: