Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i append into dict?
#13
(Aug-26-2019, 08:18 AM)ThomasL Wrote: And if you need the index of each element in an iterable (e.g. list) you should do it this way:
patients = ['Bob', 'Alice', 'Guido', 'Janet', 'Pamela'] 
for index, patient in enumerate(patients):
    print(f'{index}: {patient}')

... and if you want indices starting other than from zero use start= in enumerate Smile
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
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 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,626 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Sort a dict in dict cherry_cherry 4 78,419 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