Click here to Skip to main content
15,891,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Just doing some basic code and then this error popped up. I have no idea what I should fix everything seems fine. (Using Python)

Code:
dict = {'name':'Bob','ref':'Python','sys':'Win'}
print('\nReference:',dict['ref'])
print('n\Keys:',dict.keys()
del dict[ 'name' ]
dict['user']='Tom'
print('\nDictionary:',dict)
print('\nIs There A name Key?:','name' in dict)

Error:
C:\Python>dictionary.py
File "C:\Python\dictionary.py", line 4
del dict[ 'name' ]
^
SyntaxError: invalid syntax

What I have tried:

Solved: A ridiculous and small mistake I made. I forgot to include a parenthesis on line 3:

print('n\Keys:',dict.keys()

I should have done:

print('n\Keys:',dict.keys())
Posted
Updated 4-Apr-18 12:58pm
v2

1 solution

Try to replace
Python
print('n\Keys:',dict.keys()
del dict[ 'name' ]

with
Python
print('n\Keys:',dict.keys())
del dict[ 'name' ]
 
Share this answer
 
Comments
Christiaan van Bergen 4-Apr-18 18:53pm    
Yep, I missed that ) one too :-(
Member 13763126 4-Apr-18 18:54pm    
Yeah, I realized the ridiculous mistake I made. I can't believe I forgot something as simple as parentheses. Thank you for the help :).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900