Python's data structures(list, tuple, set, dictionary)

by - November 02, 2017

official document

Sequence Types
  list
  []
  [1, 2, 3]
  list(1, 2, 3)
  list((1, 2, 3))

  foo=(1, 2, 3)
  list(foo)

  tuple
  ()
  t = 1, 2, 3
  t = '1', '2', '3'
  u = t, (1, 2, 3)

Mapping Type
  dictionary: consist of key, value
  {}
  {'a': 1, 'b': 2, 'c': 3}
  dict()
  dict(a=1, b=2, c=3)
  dict([('a', 1), ('b', 2), ('c', 3)])

  bar=[('a', 1), ('b', 2), ('c', 3)]
  dict(bar)


set
{1, 2, 3}
{'1', '2', '3'}
set()
set('123')
set

cf)
string
('123')

You May Also Like

0 comments