-2

So my question is exactly defined in the title. That is, what is the difference between

 [(a,b),(c,d)]

and

 [[a,b],[c,d]]

and how I can turn one into another in Python.

This question is partly duplicate but the main part is how to turn one into another which in not duplicate.

HimanAB
  • 2,443
  • 8
  • 29
  • 43

1 Answers1

-3

A list is that which encloses its contents in a bracket [].

A tuple is that which encloses its contents in a parentheses ().

Lists are mutable (changeable); tuples are not.

Turning a list into a tuple is possible:

Changing a tuple to list:

list(myTuple)

Changing list to tuple:

tuple(myList)

Jossie Calderon
  • 1,393
  • 12
  • 21
  • and how I can turn one into another in Python. – HimanAB Jul 01 '16 at 20:59
  • `list` function should do it – user25064 Jul 01 '16 at 21:00
  • Downvoted because this answer is much less comprehensive than those on the marked duplicate. – miradulo Jul 01 '16 at 21:00
  • @user25064 I've edited my answer. Did it help? – Jossie Calderon Jul 01 '16 at 21:01
  • 1
    You guys are very interesting. Look at the title of the question and it is obvious that I did not know even what to search for and this was my main problem. How should I even know that this question was duplicate without knowing the terms? – HimanAB Jul 01 '16 at 21:04
  • @HimanUCC A google search for "list to tuple and back" brings [this](http://stackoverflow.com/questions/16296643/convert-tuple-to-list-and-back). Did my answer resolve your question? If it helped, make sure to click the up-arrow and if it resolved it, click the checkmark. – Jossie Calderon Jul 01 '16 at 21:06
  • @jossie Calderon If I knew it was called "tuple", why should I even ask the question? – HimanAB Jul 01 '16 at 21:07
  • @HimanUCC By Google searching "the difference between brackets and parentheses in python". – Jossie Calderon Jul 01 '16 at 21:08
  • if the downvotes bother you @HimanUCC you can just remove your question. Hopefully the duplicate and the discussion helped you out. Also, try the python.org tutorial.. Lots of basic stuff there – joel goldstick Jul 01 '16 at 21:58