InterviewSolution
Saved Bookmarks
| 1. |
Explain tuple(seq) function of the python also give example. |
|
Answer» tuple(seq) Description : The method tuple( ) is used to convert list into a tuple. Syntax : Following is the syntax for tuple( ) method : tuple (seq) Parameters : seq – This is a list to be converted into tuple. Return Value : This method returns the tuple. Example : The following example shows the usage of tupe( ) method. # !/user/bin/python aList = [123, ‘xyz’, ‘zara’, ‘abc’]; aTuple = tuple (aList) print “Tuple elements :”,aTuple Let us compile and run the above program, this will produce the followin’, result : Tuple elements : (123, ‘xyz’, ‘zara’, ‘abc’) |
|