I wrote the following two functions:
wall_cords = level.split("\n")
for cord in wall_cords:
cords = coordinate.split()
Python returns a list index out of range error. If I print the
cords variable without an index it prints all the cords in a list, however the last list is an empty list. Might that be the problem, how could that be solved?
level looks like this:
0 0=r=3 3
Assuming it is just the last, empty list you have a problem with: clearly, there is no 1st element to print in that case, so wrap it in an
if statement (for example
if len(cords)>0:; if the list is empty, do whatever is more appropriate for that circumstance.