Python Forum
From string parameter to a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
From string parameter to a dictionary
#7
No, that's a list ([]) not a dictionary ({}). You also want to skip the first line, so for l in buffer[1:]:. You still need to break down the lines with the strip method, and convert the items in the lines with the int() built-in. Then you need to make sure the student is the dictionary, set up the NAs if they aren't, and add the rating for the correct class. Adding the rating will required you to index the dictionary and the list within the dictionary.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: From string parameter to a dictionary - by ichabod801 - Oct-12-2019, 09:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  to find in dictionary given parameter 'name' and to output position Liki 10 1,397 Oct-08-2023, 06:38 AM
Last Post: Pedroski55
  How to change part of the value string in Python Dictionary? sbabu 11 3,938 Feb-12-2020, 02:25 AM
Last Post: sbabu

Forum Jump:

User Panel Messages

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