InterviewSolution
Saved Bookmarks
| 1. |
How will you find the length of the list. Give example? |
|
Answer» The len( ) function in Python is used to find the length of a list, (i.e., the number of elements in a list). Usually, the len( ) function is used to set the upper limit in a loop to read all the elements of a list. If a list contains another list as an element, len( ) returns that inner list as a single element. Example : Accessing single element >>> MySubject = [“Tamil” , “English” , “Comp. Science” , “Maths”] >>> len(MySubject) 4 |
|