Sie sind auf Seite 1von 1

List sequential collection -maps the natural numbers sequentially to integers Indices = [0 myList = [56 1 -5 2 -9 3 8 4] 12]

-maps the natural numbers sequentially to characters Indices = [0 myList = [ z 1 y 2 x 3 w 4] v]

-lists are how we store music and images (lists of lists) Dictionary non-sequential collection providing more flexible way to store information. -maps a primitive data type, called a key, to another primitive data type, called a value -so analogy to a list: natural numbers are the keys, and they allow you to access the values of the list Example mapping user name string to a password string: passwd = {"mcarlberg":"as*r&4", "mlogan": "swagtastic", "mpeguero": "blaze5"} keys = [ mcarlberg passwd = [ as*r&4 Try the following code: >>>print(passwd) >>>passwd[ mlogan ] >>>passwd[ bbuium ] = bibu >>> list(passwd.keys()) >>> list(passwd.values()) >>> mcarlberg in passwd >>> kdaley in passwd >>> passwd.get( mlogan , user doesn t exist ) >>> passwd.get( pvhorne , user doesn t exist >>> for i in passwd: print(i) >>> for i in passwd: print(passwd[i]) mlogan swagtastic mpeguero ] blaze5 ]

Das könnte Ihnen auch gefallen