+ 3

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

4th Sep 2018, 6:12 PM
Ilyich
4 ответов
+ 2
Because "a" is a set and set object does not support indexing dictionary synax is like this: {key: value, ...}
4th Sep 2018, 7:22 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
Mert Yazıcı "set" is one of types of data or "a" is dictionary or what? Sorry, can you explain it again, please
5th Sep 2018, 1:46 PM
Ilyich
+ 1
5th Sep 2018, 4:11 PM
Ilyich