whs
whs

Reputation: 29

what`s the meaning of {"item1","item2",...} in python2.7

I was confused about the structure {item1,item2,item3} in python2.7. Is it a set?

what i did :

python2.7

while

python2.3

so,what`s the meaning of {"item1","item2",...} in python2.7 ?

Upvotes: 1

Views: 211

Answers (2)

Jeanderson Candido
Jeanderson Candido

Reputation: 364

You can inspect the type an object with the type() function and figure what's going on :)

You will discover that in python2.7, a={1, 2, 3} is a Set. You might be wondering "Hey, but in python2.3 there was a set data structure as well!"

Well, the syntax was slightly different: https://docs.python.org/2/library/sets.html

Therefore, in python2.7, they have added a syntactic sugar for creating sets.

Upvotes: 4

Windyground
Windyground

Reputation: 119

type(a)

Yes, it is. You can use type().

Upvotes: 0

Related Questions