Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dictionary from file
#2
dictionary[lines[0]] = {'Hmong': lines[1], 'English': lines[2]}
I believe you want information here instead of lines.
When faced with such issues you can simply use print to see what kind of data you are dealing with and thus find mistakes immediately.
As for working with files, it is recommended to use context manager (with keyword). See an example in the docs.
Reply


Messages In This Thread
dictionary from file - by Zatoichi - Feb-11-2018, 05:56 PM
RE: dictionary from file - by j.crater - Feb-11-2018, 06:46 PM
RE: dictionary from file - by Zatoichi - Feb-11-2018, 06:56 PM
RE: dictionary from file - by j.crater - Feb-11-2018, 07:01 PM
RE: dictionary from file - by Zatoichi - Feb-11-2018, 07:07 PM
RE: dictionary from file - by j.crater - Feb-11-2018, 07:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  dictionary output to text file (beginner) Delg_Dankil 2 1,313 Jul-12-2023, 11:45 AM
Last Post: deanhystad
  Using dictionary to find the most sent emails from a file siliusu 6 7,736 Apr-22-2021, 06:07 PM
Last Post: siliusu
  Updating dictionary in another py file tommy_voet 1 5,037 Mar-28-2021, 07:25 PM
Last Post: buran
  Making a dictionary from a file instyabam 0 1,558 Oct-27-2020, 11:59 AM
Last Post: instyabam
  how can i create a dictionary of dictionaries from a file Astone 2 2,345 Oct-26-2020, 02:40 PM
Last Post: DeaD_EyE
  Convert all actions through functions, fill the dictionary from a file Astone 3 2,526 Oct-26-2020, 09:11 AM
Last Post: DeaD_EyE
  how to put text file in a dictionary infected400 2 3,048 Jan-06-2019, 04:43 PM
Last Post: micseydel
  Dictionary to .txt or .csv file stanthaman42 9 4,823 Aug-08-2018, 03:37 PM
Last Post: Vysero
  Dictionary + File Reading palmtrees 2 4,983 Nov-15-2016, 05:16 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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