I have a custom class that I have made. I make a list out of that class:
grid = [] def make_grid(r,c): global grid grid = [grid_object(x,y) for x in range(r) for y in range(c)]#Thanks Adam make_grid(row, columns) #this makes the grid class grid_object(object):#Thanks Adam def __init__(self, x, y): self.x, self.y = x, y self.item = "Blank" self.tag = "Nothing" I want to hold a couple of grid's indexs for a side quest. Below I only showed one.
baby_grid = '' def baby_side_quest(): global grid global baby_grid baby_grid = [i for i, j in grid if j.tag == "Baby_Bear"] print baby_grid I can get the baby_grid as a list. Here the code just prints:
>>>[2]
But what I really want is just:
>>> 2
How can I do that without having to write baby_grid[0] everywhere?
I just added this little function.
def get_int_from_list(list_thing): return list_thing[0] I just wonder if there is a way that I don't know of that would make my code really concise. If you have a better way of doing this I'd love you see that code.
elif grid[mama_grid[0]].enemy_killed_bool == False and grid[papa_grid[0]].enemy_killed_bool == False: grid[baby_grid[0]].been_here_text = "The baby bear is happy to still have both it's parents."