Python: Return outside function error? Tried redoing indentation, spacing, etc.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cantor
    New Member
    • Feb 2013
    • 1

    Python: Return outside function error? Tried redoing indentation, spacing, etc.

    Hi, I'm fairly new to python, and I keep getting an error 'return outside function'. I've looked around, and tried reformatting, redoing the indenting, and I still get the same error. Can anyone help me?

    Code:
    def syllableCount( someString ):
        for syllSet in myDict[someString]:
            for element in syllSet:
                if (element[-1] == 0 or element[-1] == 1):
                    return element[-1]
    Last edited by cantor; Feb 16 '13, 06:08 PM. Reason: So the indentation doesn't show in my question. But each successive line is tabbed.
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    There does not appear to be an issue with the posted code. Maybe there is an issue with myDict. Can you post a sample?

    Comment

    • dwblas
      Recognized Expert Contributor
      • May 2008
      • 626

      #3
      Also post the complete traceback that includes the offending line.

      Comment

      Working...