Also, try (works for me in Python3) rivers = {'nile' : 'egypt', 'ohio' : 'US', 'rhine' : 'germany' }
for key, value in rivers.items(): print (key) for key, value in rivers.items(): print (value) for key, value in rivers.items(): print ("The " + key + " is in the country of " + value) On Thu, Oct 11, 2018 at 12:41 PM Rajnish Sinha < rajnish.si...@infoprolearning.com> wrote: > Try > for river in rivers: > print ("The " + river + " is in the country of " + rivers[river]) > > On Wed, Oct 10, 2018 at 9:30 PM <tutor-requ...@python.org> wrote: > > > Send Tutor mailing list submissions to > > tutor@python.org > > > > To subscribe or unsubscribe via the World Wide Web, visit > > https://mail.python.org/mailman/listinfo/tutor > > or, via email, send a message with subject or body 'help' to > > tutor-requ...@python.org > > > > You can reach the person managing the list at > > tutor-ow...@python.org > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of Tutor digest..." > > Today's Topics: > > > > 1. Re: help please (Abdur-Rahmaan Janhangeer) > > 2. Re: Advanced python recommendations (Abdur-Rahmaan Janhangeer) > > 3. Re: help please (Mirage Web Studio) > > 4. Re: help please (Deepak Dixit) > > 5. Re: Advanced python recommendations (Mariam Haji) > > > > > > > > ---------- Forwarded message ---------- > > From: Abdur-Rahmaan Janhangeer <arj.pyt...@gmail.com> > > To: Michael Schmitt <mikeschmitt...@outlook.com> > > Cc: tutor <tutor@python.org> > > Bcc: > > Date: Wed, 10 Oct 2018 11:53:41 +0400 > > Subject: Re: [Tutor] help please > > i think it should have been > > > > for river in rivers instead of > > for rivers in rivers > > > > Abdur-Rahmaan Janhangeer > > https://github.com/Abdur-rahmaanJ > > Mauritius > > > > > > > > > > ---------- Forwarded message ---------- > > From: Abdur-Rahmaan Janhangeer <arj.pyt...@gmail.com> > > To: Mariam Haji <mariamhaj...@gmail.com> > > Cc: Tutor@python.org > > Bcc: > > Date: Wed, 10 Oct 2018 14:26:24 +0400 > > Subject: Re: [Tutor] Advanced python recommendations > > apart from already said, see popular python projects, and read the source > > as you would read a book. you'll discover amazing tricks, it'll broaden > > your horizon. hanging around those who achieved a good level will make > you > > level up. > > > > Abdur-Rahmaan Janhangeer > > Mauritius > > > > > > > > > > ---------- Forwarded message ---------- > > From: Mirage Web Studio <cmgcom...@gmail.com> > > To: Michael Schmitt <mikeschmitt...@outlook.com>, Python Tutor Mailing > > List <tutor@python.org> > > Cc: > > Bcc: > > Date: Wed, 10 Oct 2018 13:45:40 +0530 > > Subject: Re: [Tutor] help please > > You are using the same variable name twice. > > You may use "rivers" for the dict and "river" for values. > > Also use descriptive names for variables. For eg if you correct the above > > mistake, the next one will be this line > > > > for rivers in rivers.values(): > > print (rivers) > > > > > > and sorry for top positing. > > > > > > On Wed 10 Oct, 2018, 12:38 Michael Schmitt, <mikeschmitt...@outlook.com> > > wrote: > > > > > To whom it may concern: > > > > > > > > > I am trying to teach myself Python and ran into a problem. This is my > > code > > > > > > > > > # name of rivers and country > > > > > > rivers = {'nile' : 'egypt', 'ohio' : 'US', 'rhine' : 'germany' } > > > > > > # prints river name > > > for rivers in rivers.keys(): > > > print (rivers) > > > > > > #prints country > > > for rivers in rivers.values(): > > > print (rivers) > > > > > > # prints statement " The (river) is in the country of (country) > > > for rivers in rivers: > > > print ("The " + rivers.keys() + "is in the country of " + > > > rivers.vaules()) > > > > > > I am getting the following error > > > for rivers in rivers.values(): > > > AttributeError: 'str' object has no attribute 'values' > > > > > > Thanks for the help. > > > > > > Sincerely, > > > > > > Michael S. Schmitt > > > > > > > > > [ > > > > > > https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif > > > ]< > > > > > > https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon > > > > > > Virus-free. www.avast.com< > > > > > > https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link > > > > > > > _______________________________________________ > > > Tutor maillist - Tutor@python.org > > > To unsubscribe or change subscription options: > > > https://mail.python.org/mailman/listinfo/tutor > > > > > > > > > > > > > ---------- Forwarded message ---------- > > From: Deepak Dixit <deepakdixit0...@gmail.com> > > To: Michael Schmitt <mikeschmitt...@outlook.com> > > Cc: tutor@python.org > > Bcc: > > Date: Wed, 10 Oct 2018 12:43:46 +0530 > > Subject: Re: [Tutor] help please > > On Wed, Oct 10, 2018, 12:37 PM Michael Schmitt < > mikeschmitt...@outlook.com > > > > > wrote: > > > > > To whom it may concern: > > > > > > > > > I am trying to teach myself Python and ran into a problem. This is my > > code > > > > > > > > > # name of rivers and country > > > > > > rivers = {'nile' : 'egypt', 'ohio' : 'US', 'rhine' : 'germany' } > > > > > > # prints river name > > > for rivers in rivers.keys(): > > > print (rivers) > > > > > > #prints country > > > for rivers in rivers.values(): > > > print (rivers) > > > > > > # prints statement " The (river) is in the country of (country) > > > > > > > Why are you using "for rivers in rivers". > > Replace this for loop with :- > > > > for river in rivers: > > print ("The " + river + "is in the country of " + rivers.get(river)) > > > > for rivers in rivers: > > > print ("The " + rivers.keys() + "is in the country of " + > > > rivers.vaules()) > > > > > > I am getting the following error > > > for rivers in rivers.values(): > > > AttributeError: 'str' object has no attribute 'values' > > > > > > Thanks for the help. > > > > > > Sincerely, > > > > > > Michael S. Schmitt > > > > > > > > > [ > > > > > > https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif > > > ]< > > > > > > https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon > > > > > > Virus-free. www.avast.com< > > > > > > https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link > > > > > > > _______________________________________________ > > > Tutor maillist - Tutor@python.org > > > To unsubscribe or change subscription options: > > > https://mail.python.org/mailman/listinfo/tutor > > > > > > > > > > > > > ---------- Forwarded message ---------- > > From: Mariam Haji <mariamhaj...@gmail.com> > > To: > > Cc: tutor@python.org > > Bcc: > > Date: Wed, 10 Oct 2018 12:53:59 +0300 > > Subject: Re: [Tutor] Advanced python recommendations > > Thank you all for the above tips. > > I actually did python 2 a friend sent it to me. And my current challenge > > with the projects bit is how to pseudo-code and which approach to use as > I > > am not very familiar with the entire python syntax and how I can use it > and > > as well as python algorithms. > > > > So like I get a problem to create a simple loop or remove duplicates > from a > > list and that just doesn't process in my head and I always end up having > to > > google, then build from there. > > > > But thank you, I guess i just have to be patient it's been 3 months > since I > > started coding and development I am more of a front-end developer. > > > > I guess I just need to learn how to break down the problems and know what > > to use where. > > > > On Wed, Oct 10, 2018 at 12:44 PM Mark Lawrence <breamore...@gmail.com> > > wrote: > > > > > On 10/10/18 02:22, boB Stepp wrote: > > > > On Tue, Oct 9, 2018 at 6:54 PM Mariam Haji <mariamhaj...@gmail.com> > > > wrote: > > > >> > > > >> Hi guys, I am on the last exercises of learn python the hard by > Zed.A > > > Shaw and I am looking for recommendations on what to follow next or > what > > > book to try next to advance my python skills to intermediate level. > > > > > > > > If you are a fan of Zed Shaw's approach, I noticed while at Barnes & > > > > Noble a while back that he has released a sequel to the book you > > > > cited, but only for the Python 3 version. You may be interested in > > > > that. > > > > > > > > But I imagine taking time to imagine, detail and write the code for > > > > projects would help you the most, as the others have said. > > > > > > > > > > > > > > After the disgraceful way that Zed Shaw wrote about Python 3 > > > https://learnpythonthehardway.org/book/nopython3.html I wouldn't touch > > > his stuff with a 100 foot long disinfected barge pole. Just a few > > > months after this article he came out with the Python 3 book you > > > reference above, presumably because he was losing cash. > > > > > > -- > > > My fellow Pythonistas, ask not what our language can do for you, ask > > > what you can do for our language. > > > > > > Mark Lawrence > > > > > > _______________________________________________ > > > Tutor maillist - Tutor@python.org > > > To unsubscribe or change subscription options: > > > https://mail.python.org/mailman/listinfo/tutor > > > > > > > > > -- > > *Regards,* > > *Mariam.* > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > https://mail.python.org/mailman/listinfo/tutor > > > > > -- > > Regards, > > > > *Rajnish Sinha* > > Project Manager > > *----------------------------------------------------------* > > > > *InfoPro Learning Inc. * > > 103 Morgan Lane | Suite 102 |Plainsboro, NJ 08536 > > T: (609) 606-9010, Extn: 1549 > > F: (609) 750-0981 > > E: rajnish.si...@infoprolearning.com > > W: www.infoprolearning.com > > *eLearning Solutions **I** Training Delivery **I* *Consulting* *I* *Mobile > Learning** I* *Gnosis LMS** I** Custom Application Development* > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor