mardi 14 janvier 2020

my comparison function didn't gives the right answer

whats wrong with this fucntion? it gives right ans just with the if condition in all other cases it gives wrong ans. The four compass points can be abbreviated by single-letter strings as “N”, “E”, “S”, and “W”. Write a function turn_clockwise that takes one of these four compass points as its parameter, and returns the next compass point in the clockwise direction.

def turn_clockwise(v):
    if "N" == "N":
       return "E"
    elif "E" == "E":
       return "S"
    elif "S" == "S":
       return "W"
    elif "W" == "W":
       return "N"
    else:
       return "SORRY"
a = turn_clockwise("W") == "N"
print(a)

Aucun commentaire:

Enregistrer un commentaire