Hello,
I'm learning Python from an online course and could not figure out why my
super-simple code had a syntax error. I finally submitted the code I
thought was right as the answer to the problem and it was accepted as
correct; however, I could never get Spider to execute it.
bears = {"Grizzly":"angry", "Brown":"friendly", "Polar":"friendly"}
for bear in bears:
if bears[bear] == "friendly"
print("Hello, "+bear+" bear!")
else:
print("odd")
The question was to come up with correct 'if' statement in line 3. I
thought I was missing something soooooo basic I couldn't see it, but it is
correct. When I tested it in the console it was evaluating correctly, but
in the editor...
File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py",
line 710, in runfile
execfile(filename, namespace)
File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py",
line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "F:/directory/delete.py", line 9
if bears[bear] == "friendly"
^
SyntaxError: invalid syntax
...and the editor shows a syntax error next to the line number in the
editor, too. It's making me kind of crazy.
Thanks for any help.
A
--
You received this message because you are subscribed to the Google Groups
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.