Python Classroom Series – 27/May/2021

Python Lists continued

  • Refer Here for the python notebook

  • Reorder Items with sort() and sorted()

    • The list method sort() with sort the list itself , in place
    • The general function sorted() returns a sorted copy of the list Preview Preview
  • Copying the list with assignment Preview

  • Copying the list with copy(), list() or slice Preview Preview

  • The copy() function works well if the list values are all immutable. A change in original will not reflect in the copies as long as values are immutable

  • But if we have items in a list which mutable (list in list) then change in original will be reflected in copies also Preview Preview

  • To fix this, we need use python standard library has a module copy which has a deepcopy() method Preview

Problem 3 in project Euler

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin