User Profile

Collapse

Profile Sidebar

Collapse
ericyan1234
ericyan1234
Last Activity: Jun 7 '13, 05:33 PM
Joined: Jun 2 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • I tried your suggested code but it didn't work for me?...
    See more | Go to post

    Leave a comment:


  • 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()
    it results in a syntax error when i try to pull the value of the variable from the previous function.
    Also, the spaces/indents didnt show up sor...
    See more | Go to post
    Last edited by Rabbit; Jun 7 '13, 03:30 PM. Reason: Please use code tags when posting code.

    Leave a comment:


  • ericyan1234
    started a topic Can I store a variable inside of a function?

    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?
    See more | Go to post

  • ericyan1234
    replied to Can't Assign to Literal Syntax Error
    Thanks guys I redid it and this
    # Write your function below!
    Code:
    def fizz_count(x):
        count = 0
        for word in x:
            if word == 'fizz':
                count +=1
        return count
    worked
    See more | Go to post
    Last edited by bvdet; Jun 2 '13, 07:08 PM. Reason: PLEASE use code tags when posting code [code]....[/code]

    Leave a comment:


  • ericyan1234
    replied to Can't Assign to Literal Syntax Error
    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.
    See more | Go to post

    Leave a comment:


  • ericyan1234
    started a topic Can't Assign to Literal Syntax Error

    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 count
    See more | Go to post
    Last 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
Working...