Python Forum
python dictionary syntax - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: python dictionary syntax (/thread-39857.html)



python dictionary syntax - nafshar - Apr-24-2023

can someone explain how the following dictionary definition is supposed to work?
Pycharm shows it as a syntaxial error, but the class I am taking shows it valid:

payload = {'email': 'password': 'badpass'}
Thank you


RE: python dictionary syntax - nafshar - Apr-24-2023

(Apr-24-2023, 06:26 PM)nafshar Wrote: can someone explain how the following dictionary definition is supposed to work?
Pycharm shows it as a syntaxial error, but the class I am taking shows it valid:

payload = {'email': 'password': 'badpass'}
Thank you

It appears this is an error after all. It was just reported in the on-line class as well. Sorry about the confusion and thank you for looking at it.


RE: python dictionary syntax - snippsat - Apr-24-2023

A dictionary work with key and values pair,so 3 item dos not work well.
>>> payload = {'email': 'some@thing', 'password': 'badpass'}
>>> payload = {'email': 'some@thing', 'password': 'badpass'}
>>> payload['email']
'some@thing'
>>> payload['password']
'badpass'