Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i append into dict?
#11
(Aug-22-2019, 10:46 AM)perfringo Wrote: In Python you should never do this:

>>> patients = ['Bob', 'Alice', 'Guido', 'Janet', 'Pamela'] 
>>> for x in range(len(patients)):
...     print(patients[x])
In Python you should iterate directly over items:

>>> for patient in patients: 
...     print(patient) 

Thank you!

I'm still learning, and I guess I'm also in the process of distinguishing between the code I can write, and the code I SHOULD write. I hope that with time, I'm going to be better at writing a neater and more suitable code. I am grateful to all of you who have made me aware of how to do it better. Heart

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Messages In This Thread
How do i append into dict? - by Gateux - Aug-21-2019, 04:22 AM
RE: How do i append into dict? - by Malt - Aug-21-2019, 04:50 AM
RE: How do i append into dict? - by ThomasL - Aug-21-2019, 05:40 AM
RE: How do i append into dict? - by perfringo - Aug-21-2019, 06:59 AM
RE: How do i append into dict? - by Malt - Aug-22-2019, 04:24 AM
RE: How do i append into dict? - by perfringo - Aug-22-2019, 05:41 AM
RE: How do i append into dict? - by Malt - Aug-22-2019, 09:11 AM
RE: How do i append into dict? - by perfringo - Aug-22-2019, 10:46 AM
RE: How do i append into dict? - by newbieAuggie2019 - Aug-26-2019, 05:57 AM
RE: How do i append into dict? - by ThomasL - Aug-26-2019, 08:18 AM
RE: How do i append into dict? - by perfringo - Aug-26-2019, 09:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 2,711 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Sort a dict in dict cherry_cherry 4 97,118 Apr-08-2020, 12:25 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020