1 Replies - 153 Views - Last Post: 10 February 2019 - 04:42 PM Rate Topic: -----

#1 DrooBdoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 20-July 12

count number of elements in dictionary

Posted 10 February 2019 - 04:17 PM

Hi everyone,
I'm new to python and been playing around a bit with NFL data. I'm trying to determine the best way to count the number of elements in a set. The set is part of a dictionary.
I have tried len() and sorted(), but this has gotten me nada. I have no idea, I keep running into errors such as non itterable items, etc.
Structure is as follows:
Players ={}

for i in play:
    for key, value in i.items()
        if(key == 'clubcode'):
            team = value
        elif(key== 'playerName'):
            if value not in Players:
                Players[value]=set()
            Players[value].add(team)
        




Any help would be greatly appreciated.
Thanks

This post has been edited by DrooBdoo: 10 February 2019 - 04:26 PM


Is This A Good Question/Topic? 0
  • +

Replies To: count number of elements in dictionary

#2 DrooBdoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 20-July 12

Re: count number of elements in dictionary

Posted 10 February 2019 - 04:42 PM

I just realized what I was doing wrong, I'm coming from a c++ background.. Confused myself severely for a sec.
Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1