Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary Methods
#1
Hi,

I just wanted to know if there is a way to count the individual keys in a dictionary and print the amount of times they appear.
Reply
#2
Lets say you have a dictionary named mydict, then
print(len(mydict.keys()))
or
print(len(mydict))
>>> zz = {'a':123, 'b':456, 'c':789}
>>> len(zz)
3
Reply
#3
I think each key can appear only once in a standard dict. A standard dict doesn't permit key duplication.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dictionary methods Wolfpack2605 2 2,898 Jan-05-2018, 07:55 PM
Last Post: jajjaja

Forum Jump:

User Panel Messages

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