Sun Aug 08 2021

List Data Structure

File Name: list-data-structure.py

#!/usr/bin/evn python

listData = ['Lion', 'Eagle', 'Penguin', 2017, 2018];

print ("Values in the list", listData)

listData.insert(3, 'Parrot')

print ("After insering value at 4th posting in the list", listData)

listData.append( 'Pigeon')

print ("After append value in the list", listData)

listData[3] = 'Tiger';

print ("After value update of 4th position in the list", listData)

del listData[0]

print ("After deleting value in the list", listData)


# ***** Output *****
# Values in the list ['Lion', 'Eagle', 'Penguin', 2017, 2018]
# After insering value at 4th posting in the list ['Lion', 'Eagle', 'Penguin', 'Parrot', 2017, 2018]
# After append value in the list ['Lion', 'Eagle', 'Penguin', 'Parrot', 2017, 2018, 'Pigeon']
# After value update of 4th position in the list ['Lion', 'Eagle', 'Penguin', 'Tiger', 2017, 2018, 'Pigeon']
# After deleting value in the list ['Eagle', 'Penguin', 'Tiger', 2017, 2018, 'Pigeon']
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.