Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
list1 = [10,"rahul",'z']
print "Elements of List1 are: "
print list1
list1.append(10.45) # Appending the list.
print "\nList1 after appending: "
print list1
list2 = [20,"dinesh",10,1354,'kapil']
print "\nElements of List2 are: "
print list2
print "\nMin value of list1: ", min(list1) #Returns the minimum value from the list given.
print "Max value of list 1:", max(list1) #Returns the largest value from the given list.
print "length of list 1:", len(list1)
print "length of list2:", len(list2) #Returns number of elements in a list.
print cmp(list1,list2) #Compares the two list.
print list2.index(1354) #Returns the index value of the object.
print list1.index('rahul')
list2.count('kapil') #It returns the number of times an object is repeated in list.
"""pop()/pop(index) #Returns the last object or the specified indexed object. It removes the popped object.
insert(index,object) #Insert an object at the given index.
extend(sequence) #It adds the sequence to existing list.
remove(object) #It removes the object from the given List.
reverse() #Reverse the position of all the elements of a list.
sort() #It is used to sort the elements of the List.
list1=[101,981,'abcd','xyz','m']
list2=['aman','shekhar',100.45,98.2]
list3=[101,981,'abcd','xyz','m']
print cmp(list1,list2)
print cmp(list2,list1)
print cmp(list3,list1) #list(sequence) #Takes sequence types and converts them to lists."""
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more