From 4ec037b3ad2d1030ba2b459b897f619bdc18853f Mon Sep 17 00:00:00 2001 From: Fred Z Date: Sat, 17 Feb 2018 01:53:22 +0100 Subject: [PATCH] Ajout val de retour sur traitement des directions Mauvais choix, l'impression n'apporte rien et l'abscence de retour manque pour la suite. Retour d'une erreur: "undLocalError: local variable 'direction' referenced before assignment" --- roboc/map.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/roboc/map.py b/roboc/map.py index 8097e2e..a28d9da 100644 --- a/roboc/map.py +++ b/roboc/map.py @@ -141,12 +141,10 @@ class Map: # decompose le mouvement try: # on recupere le 1er caractere (la direction) direction = move[0] - except IndexError as except_detail: - print("IndexError: «{}»".format(except_detail)) - # return 0 - except TypeError as except_detail: - print("TypeError: «{}»-«{}»".format(except_detail, move)) - # return 0 + except IndexError: + return 0 + except TypeError: + return 0 if len(move[1:]) > 0: # on recupere les caractere suivants (dist) try: @@ -159,8 +157,6 @@ class Map: steps = 0 # direction non conforme - # FIXME: UnboundLocalError: local variable 'direction' \ - # referenced before assignment if direction not in DIRECTIONS: move_status = 0