Python Forum
Looping through a dictionary for every other value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping through a dictionary for every other value
#11
(Jan-25-2018, 05:48 PM)j.crater Wrote: The thing is dictfunc() function will not be very helpful because it does not return anything.

Really? Because if I print letlist it returns values. So I am just trying to get letlist into that function. That is initially why I tried using global because I didn't realize you could pass functions to other values.

Here is the output if I add a print for letlist:
{0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f', 6: 'g', 7: 'h', 8: 'i', 9: 'j', 10: 'k', 11: 'l', 12: 'm', 13: 'n', 14: 'o', 15: 'p', 16: 'q', 17: 'r', 18: 's', 19: 't', 20: 'u', 21: 'v', 22: 'w', 23: 'x', 24: 'y', 25: 'z'}

import string
def dictfunc():
    letlist = dict(enumerate(string.ascii_lowercase))
    print (letlist)
dictfunc()
Reply


Messages In This Thread
RE: Looping through a dictionary for every other value - by fad3r - Jan-25-2018, 06:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Looping to Create Nested Dictionary gngu2691 10 33,803 Jun-22-2018, 04:11 PM
Last Post: anickone

Forum Jump:

User Panel Messages

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