what is the difference between tuple and list
what is the difference between tuple and list
Page 1 of 16 Replies - 881 Views - Last Post: 17 July 2012 - 07:49 PM
Replies To: what is the difference between tuple and list
#2
Re: what is the difference between tuple and list
Posted 14 May 2012 - 05:44 AM
A tuple is immutable. This means that once the tuple is created, you can't add or remove elements from it, however, tuples can be processed more quickly.
Lists are mutable, you can add or remove elements from a list at any time.
When in doubt, use a list.
tuples are declared like this:
Lists are declared like this:
Lists are mutable, you can add or remove elements from a list at any time.
When in doubt, use a list.
tuples are declared like this:
a = (1,2,3,) #The extra comma is on purpose!
Lists are declared like this:
a = [1,2,3]
This post has been edited by atraub: 14 May 2012 - 05:52 AM
#3
Re: what is the difference between tuple and list
Posted 17 July 2012 - 01:34 PM
sai_saketh92, on 14 May 2012 - 04:36 AM, said:
what is the difference between tuple and list
Here ya go
http://lmgtfy.com/?q...uple+and+a+list
#4
Re: what is the difference between tuple and list
Posted 17 July 2012 - 01:43 PM
A Tuple can be made up of different datatypes
("String", 0,)
#5
Re: what is the difference between tuple and list
Posted 17 July 2012 - 01:52 PM
So can lists:
["Another String", 1, 6.235]
#6
Re: what is the difference between tuple and list
Posted 17 July 2012 - 03:42 PM
All the examples I seen make it look like that can only handle a single "type".
Dynamic typing argh
I'm more a statically typed, with a dash of functional coder.
I use a statically typed language where it immutable be default (mutability has stated explicitly).
So lists can be Immutable or mutable, but they can only contain objects of a particular specified type or a derivative of it.
Dynamic typing argh
I'm more a statically typed, with a dash of functional coder.
I use a statically typed language where it immutable be default (mutability has stated explicitly).
So lists can be Immutable or mutable, but they can only contain objects of a particular specified type or a derivative of it.
Spoiler
This post has been edited by AdamSpeight2008: 17 July 2012 - 03:49 PM
#7
Re: what is the difference between tuple and list
Posted 17 July 2012 - 07:49 PM
Why would you resurrect a post that's been dead for two months just to add a lmgtfy link?
This post has been edited by atraub: 17 July 2012 - 07:52 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|