Skip to content

Instantly share code, notes, and snippets.

@xrl
Last active December 22, 2015 04:29
Show Gist options
  • Save xrl/6417809 to your computer and use it in GitHub Desktop.
Save xrl/6417809 to your computer and use it in GitHub Desktop.
def get_coords():
coords = raw_input("coords x,y: ")
coords.split(",")
# Gotta how big the split is
if(len(coords.split(",")) == 2):
# Python can extra lists using =
x_str,y_str = coords.split(",")
try:
x = int(x_str)
except ValueError:
print("error, input again")
return get_coords()
#
try:
y = int(y_str)
except ValueError:
print("error, input again")
return get_coords()
#
return x,y
else:
print("error, input again")
return get_coords()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment