code.py - ' List' my_list = [1,5,2,3] sorting =...

This preview shows page 1 out of 1 page.

''' List'''my_list = [1,5,2,3]sorting = my_list.sort()'''print(my_list)'''# [1, 2, 3, 5]reversing = my_list.reverse()'''print(my_list)'''#[5, 3, 2, 1]appending = my_list.append(7)'''print(my_list)'''#[5, 3, 2, 1, 7]reassign = my_list[0] = 'start in''''print(my_list)'''#['start in', 3, 2, 1, 7]'''How do you index on a lested list?'''x = [1,1,[1,2]]'''print(x[2][1])'''#2'''dictionaries'''my_dict = {'key1':'value','key2':'value2'}prices_lookup = {'apple':2.99,'oranges':1.99}#print(prices_lookup['apple'])# 2.99#FYI In order for you to call a dictionary,#it has to be on a [] bracket.d={'dictionary1':[1,2,3],'dictionary2':{'2':'no'}}print(d['dictionary1'][1])
End of preview. Want to read the entire page?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
CharlesD.Allison
Tags
Associative array, MySet, Tindex, tcounted

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture