Investing in Stock


I have followed the instructions of the exercise and I am both getting a syntax error

"File "python", line 3
"apple": 0
SyntaxError: invalid syntax"

Along with it returning

"Oops, try again. Did you remember to create a dictionary called stock? "

I do not believe that my code should be acting this way, any and all help will be greatly appreciated.

    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
    "banana": 6
    "apple": 0
    "orange": 32
    "pear": 15


Solved it. My code was lacking the correct commas in my stock.


Could you describe more specifically what "lacking correct commas" mean?
I've met the same problem but can't find a solution.

stock = {
    "banana": 6
    "apple": 0
    "orange": 32
    "pear": 15

Funny part is that the error is on "apple"

File "python", line 10
"apple": 0
^ (it shows on a quotation mark after apple"
SyntaxError: invalid syntax

So it is fine with quotation marks in "banana".
And i also have another dictionary before "stock" and it seems to work fine.


At the end of the number you need to have commas, so 6, 0, etc to separate the items.

"banana: : 6,

and so on.


I didn't understood your response before, because of linguistic error.
In my native language "commas" also refers sometimes to quotation marks.
And the error I got was also pointing at the quotation mark.
Interesting thing to note in future.

Thank you.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.