#NoPayJan Offer - Access all CloudxLab Courses for free between 1st to 31st Jan

  Enroll Now >>

List Methods

Just like strings, you can check for methods for lists as well using dir and help. Some important methods are like append, extend and sort.

  • append adds a new element to the list,
  • extend takes a list as an argument and appends all of the elements,
  • sort arranges the elements of the list from small to large.

Understand the code and make use of notebook to figure out the results,

a = [23,12,32,1,2,34,56]

Enter the number printed


Enter the sum of all elements within a

print(a[2] + a[7])

Enter the number printed

Some other functions are,

  • sum() only works when the list elements are numbers to calculate the sum of all elements
  • other functions (max(), len(), etc.) work with lists of strings and other types that can be comparable.

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...