Python List del MethodPython Functions

Difficulty Level:
Difficulty Level:

The del list() method deletes the (num+1)th element.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

list = ['MIT', 'Stanford','NWU', 2012, 2019]

print("list is:  ", list)
del list[2]
print("Delete the third element : ", list)

Output:

list is:   ['MIT', 'Stanford', 'NWU', 2012, 2019]
Delete the third element :  ['MIT', 'Stanford', 2012, 2019]

Syntax

del list[num]

Parameters

The method doesn’t take any parameters.

Return Value

It doesn’t return any values.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us