Skip to content
Advertisement

I’m getting an error when comparing in text file with python

X,Y Matrix list

In this matrix, like adding items such as 1×3,3×3,5×5 to the map, check each item according to the item id and if it is 1×3 and start from the starting coordinate, for example X:5 Y1, if the item is horizontal and it is , then push it to the y-axis once and to the x-axis 3 times. I would like to add the id I assigned and add the ones with the same id separately, for example, there are two items with item id 82, but one is number 1, the other is number 2 and 0. I want to compare the shortest path from the non-item squares by scanning them one by one. but I’m having trouble reading the txt files with the dimensions of the items. I was reading it directly as .read() before and I noticed that the items were measuring incorrectly.

The code where I check the item sizes

JavaScript

The code where I add the items to the matrix

JavaScript

And this is the error I get

JavaScript

size function returning: “!:!” where am i doing wrong:(

My full test.py code

JavaScript

And example propsize file

JavaScript

And example item before processing(82 is item number , 0 is x cordinate and 1 is y cordinate and “v” is rotation type

JavaScript

Advertisement

Answer

You are getting a ValueError, but the problem with your code isn’t this.


JavaScript

This is the problem. Creating Y1 Y2 Y3Y20 is a very bad idea, try something like this instead:

JavaScript

then you can access it this way:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement