Last active
December 22, 2015 04:29
-
-
Save xrl/6417809 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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