Day: March 19, 2022

Exception Handling for Lists and Sets

Exception Handling for lists and sets¶ In [1]: l = [1, 2, 3, 4] In [2]: l[4] ————————————————————————— IndexError Traceback (most recent call last) /tmp/ipykernel_99/3011213518.py in <module> —-> 1 l[4] IndexError: list index out of range In [3]: l.pop(4) ————————————————————————— IndexError Traceback (most recent call last) /tmp/ipykernel_99/4109986001.py in <module> —-> 1 l.pop(4) IndexError: pop index out of range …

Exception Handling for Lists and Sets Read More »

Sorting List of Delimited Strings

Sorting list of delimited strings¶ Let us perform a task to sort employees based upon their salary using employees list. We will create employee list in the form of comma separated or delimited strings. Employee list will contain employee id, email and salary. In [1]: employees = [ ‘1,ktrett0@independent.co.uk,6998.95’, ‘2,khaddock1@deviantart.com,10572.4’, ‘3,ecraft2@dell.com,3967.35’, ‘4,drussam3@t-online.de,17672.44’, ‘5,graigatt4@github.io,11660.67’, ‘6,bjaxon5@salon.com,18614.93’, ‘7,araulston6@list-manage.com,11550.75’, ‘8,mcobb7@mozilla.com,17016.15’, …

Sorting List of Delimited Strings Read More »