append() method for list

append() takes exactly one argument ( not more than one ) and adds at the end of the list.
my_list=['Alex','Ronald','John']
my_list.append('Ravi')
print(my_list)
Output is here
['Alex', 'Ronald', 'John', 'Ravi']

Appending one more list

my_list=['Alex','Ronald','John']
my_list2=['Ravi','John','Ronald']
my_list.append(my_list2)
print(my_list)
Output is here
['Alex', 'Ronald', 'John', ['Ravi', 'John', 'Ronald']]
Using len() to check the length of the list
my_list=['Alex','Ronald','John']
print("Length before append : ",len(my_list))
my_list.append('Ravi')
print("Length after append : ",len(my_list))
print(my_list)
Output is here
Length before append :  3
Length after append :  4
['Alex', 'Ronald', 'John', 'Ravi']
All list methods

if else for loop


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer