mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-03-14 05:06:55 +01:00
Rework of module 03
This commit is contained in:
@@ -14,16 +14,17 @@ if __name__ == "__main__":
|
||||
try:
|
||||
if len(argv) != 2:
|
||||
raise Exception("Invalid number of args")
|
||||
print(f'Parsing coordinates: "{argv[1]}"')
|
||||
args = argv[1].split(",")
|
||||
if len(args) != 3:
|
||||
raise Exception(
|
||||
"Invalid argument format." + 'Try like this : "15,64,78"'
|
||||
)
|
||||
int_args = (int(args[0]), int(args[1]), int(args[2]))
|
||||
print("Parsing coordinates:", args[1])
|
||||
print(f"Parsed position: {int_args}")
|
||||
print_distance((0, 0, 0), int_args)
|
||||
except ValueError as err:
|
||||
print(f'Parsing invalid coordinates: "{argv[1]}"')
|
||||
print(f'Invalid coordinates: "{argv[1]}"')
|
||||
print(err)
|
||||
except Exception as err:
|
||||
print(err)
|
||||
|
||||
Reference in New Issue
Block a user