Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get data out of connl-file
#2
I think your index error on the deque is because your while loop upping/lowering the index. If the last item in that direction matches the while condition, the index will get too large/small for the deque, and give you an error. Like:

breakfast = ['spam', 'spam', 'spam', 'eggs']
index = 0
while True:
    print(breakfast[index])
    index += 1
The other problem I think has to do with the keys to your default dict being the third item, which is not unique. Each key can only hold one value. I think you want to append rather than updating:

factors = defautdict(list)
for num, factor in [(2, 1), (2, 2), (3, 1), (3, 3), (4, 1), (4, 2), (4, 4)]:
    factors[num].append(factor)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Get data out of connl-file - by MattaFX - Jun-19-2017, 09:35 AM
RE: Get data out of connl-file - by ichabod801 - Jun-19-2017, 09:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  xml file creation from an XML file template and data from an excel file naji_python 1 2,140 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  How to save CSV file data into the Azure Data Lake Storage Gen2 table? Mangesh121 0 2,137 Jun-26-2020, 11:59 AM
Last Post: Mangesh121

Forum Jump:

User Panel Messages

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