Dictionaries | SoloLearn: Learn to code for FREE!

+1

Dictionaries

a={1, 2} What does it mean? If i try to do "print(a[1])", there's error. I thought, that this script means "0" as value and 1,2 as keys(a={1:0,2:0}), but if it was true, there wouldn't be any error. Help

9/4/2018 6:12:40 PM

Ilyich

4 Answers

New Answer

+3

Because "a" is a set and set object does not support indexing dictionary synax is like this: {key: value, ...}

+2

https://www.programiz.com/python-programming/set https://www.w3schools.com/python/python_dictionaries.asp

+1

Mert Yazıcı "set" is one of types of data or "a" is dictionary or what? Sorry, can you explain it again, please

+1

Mert Yazıcı thaks!