Now the constant values here are Name and the Phone Numbers which are called as the keys. To understand better, think of a phone directory where hundreds and thousands of names and their corresponding numbers have been added. My_list.sort(reverse=True) #sort original listĭictionaries are used to store key-value pairs. Print(sorted(my_list)) #print sorted list but not change original Print(my_unt(10)) #find count of the element Print(my_list.index(10)) #find index of element that occurs first The sorted() has a return type whereas the sort() modifies the original list. The sorted() and sort() functions do the same thing, that is to sort the values of the list.The count() function finds the count of the value passed to it.The index() function finds the index value of value passed where it has been encountered the first time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |