Session 04 homework and labs

When would one choose to create and use a view rather than use the underlying dictionary? 

----- Original Message -----

From: "CAROLYN" <gosunfish@comcast.net> 
To: "UWPCE-PythonCert/IntroToPython" <reply@reply.github.com> 
Cc: "UWPCE-PythonCert/IntroToPython" <IntroToPython@noreply.github.com> 
Sent: Tuesday, November 4, 2014 9:30:11 AM 
Subject: Re: [IntroToPython] Session 04 homework and labs (#52) 

Nevermind. I found the answer in session 4. 

----- Original Message -----

From: "CAROLYN" <gosunfish@comcast.net> 
To: "UWPCE-PythonCert/IntroToPython" <reply@reply.github.com> 
Cc: "UWPCE-PythonCert/IntroToPython" <IntroToPython@noreply.github.com> 
Sent: Tuesday, November 4, 2014 9:27:03 AM 
Subject: Re: [IntroToPython] Session 04 homework and labs (#52) 

No, I did not catch the difference between viewkeys() and keys(). Where can I get an explanation? 

----- Original Message -----

From: "Christopher H.Barker, PhD" <notifications@github.com> 
To: "UWPCE-PythonCert/IntroToPython" <IntroToPython@noreply.github.com> 
Cc: "gosunfish" <gosunfish@comcast.net> 
Sent: Sunday, November 2, 2014 4:12:10 PM 
Subject: Re: [IntroToPython] Session 04 homework and labs (#52) 



In Students/CarolynEvans/session04/labs.py: 
> @@ -0,0 +1,89 @@
> +
> +def dict_lab():
> +    # 1.
> +    d = {'name': 'Chris', 'city': 'Seattle', 'cake': 'Chocolate'}
> +    print d
> +    d.pop('cake')
> +    print d
> +    d.setdefault('fruit', 'Mango')
> +    print d
> +    print d.viewkeys() 


did you catch the difference between viewkeys() and keys() ? In this case, either will work fine. 

— 
Reply to this email directly or view it on GitHub .