Reputation: 31
So i want to ask the user for the coordinates (i.e. (0,0)) and pass them on to find the neighbors. How do I effectively access the tuple to have it passed on to get my result? It wont recognize it as it is a string and with the parenthesis. Some Error Warning with the input specified after the dash:
networkx.exception.NetworkXError: The node ('(', '0') is not in the graph. - (0,0)
networkx.exception.NetworkXError: The node ('0', '0') is not in the graph. - 00
networkx.exception.NetworkXError: The node ('0', ',') is not in the graph. - 0,0
def get_neighbors(self, coords):
return list(nx.grid_2d_graph(*self.get_face_value().shape).neighbors((coords[0], coords[1])))
def __repr__(self):
x = tuple(input('What coordinates in the array shown above would you like to use? ').strip(','))
return 'Adjacent values at the coordinates specified of side ' + str(self.get_side_chosen()) + ' are ' + \
str(self.get_neighbors(x))
Upvotes: 0
Views: 79
Reputation: 34
Why don't you sterilize your inputs so you only allow numbers and require two different inputs? Asking a human to put in whatever they want is asking for issues.
In any case the trouble is that your format is a string and your needing decimal form. Wrap your coords with int()
Upvotes: 1