How to fix syntax error message?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ashley Bridges
    New Member
    • Jan 2011
    • 1

    How to fix syntax error message?

    Hi,

    I apologize if this seems like a silly question, but I am a new user of python, never programmed before. I am writing a simple program and I get an "invalid syntax" message concerning this line of code:
    [monthlySales=fl oat(monthlySale s)]

    when I try to run the program the only message I am given is this exactly:
    "There's an error in your program, invalid syntax"

    the word [monthlySales] at the beginning of that line of code is highlighted pink.

    This is for an assignment, and try as I might, I just cannot figure it out on my own...

    Any help or insight would be greatly appreciated!!

    Thanks
    Ashley
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Ashley,

    That is invalid syntax. You cannot make an assignment inside brackets. Example:
    Code:
    >>> N = 23
    >>> [N = float(N)]
    Traceback (  File "<interactive input>", line 1
        [N = float(N)]
           ^
    SyntaxError: invalid syntax
    >>> N = float(N)
    >>> N
    23.0
    >>>

    Comment

    Working...