Tuple is like list but unlike in structure and functionality. first basic difference is can be figured out by the structure. List elements are enclosed with '[]' brackets but tuple elements are enclosed with '()' parentheses. Few properties of tuple:- 1. It is faster than list. 2. Unlike list, tuple is immutable, i.e. tuple's data cannot be changed once created, we should use tuple if we want our data to be safe from accidental change. As you can see in title picture, you are allowed to see but cannot touch it. 3. We can use tuple as key in dictionaries whereas this is not the case with list, we can’t use list as key in dictionary <Link this post (dictionary) will be available on 16 March 2018>. Examples:- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 myTuple= tuple ( 'Python' ) # it takes only one parameter print (myTuple) #it will break down each character into separate elements, just l...
Comments
Post a Comment
Thanks in anticipation.