I've checked other questions about this error but they look a bit different from what I'm trying to do, no direct user input for one thing so hope you can help.
Working with values in a grid I am trying to write code that works out the difference between two locations on the grid. Playerpos is the current position of a player, bossgroup represents a fixed point on the grid (or map) and is taken from a parallel map of bosses.
# playerposition, as row,column...
playerpos = [0,0]
a = playerpos[0]
b = playerpos[1]
# here I make it so the player can set a location in the bossmap
# as a fixed location called bossgroup. Build a HQ in game terms...
bossmap[playerpos[1]][playerpos[0]] = bossgroup
OR - there's a count value where the above statement is used if count is below the count value, but if above, bossgroup
is created with the following statement. So far the invalid literal error always occurs below the count but I include both statements here just in case it's relevant.
# seems necessary to fomat bossgroup, to look like "1, 7" rather than "17"
bossgroup = str(a)+str(", ")+str(b)
# here coordinates are striped from the string describing bossgroup
# and made into integers so math can be done....
c = int(bossgroup[0])
d = int(bossgroup[3])
# now i want to turn the differences between the two sets of row and columns in x and y values and do math to them, including using abs() to flip negs to positives
x = a - c
y = b - c
...
However the problem I have is I keep getting this error-
d = int(bossgroup[3])
ValueError: invalid literal for int() with base 10: ''
Strangely, this doesn't always happen, it depends on the math stuff I do, but for now I think I've put enough code on the screen for your assistance, hope it is clear enough and sufficient to see what I'm doing wrong.