Apr-18-2021, 07:22 PM
Hello everybody,
I have a task that I don't quite understand how to tackle.
At the moment I have written this code but I do not get the result that it should give, I leave the code:
TASK LINK
I have a task that I don't quite understand how to tackle.
At the moment I have written this code but I do not get the result that it should give, I leave the code:
movement = str(input("Write movements: ")) m = list(movement) lon = len(movement) Turnleft = 0 Turnright = 0 Up = 0 Down = 0 Leftside = 0 Rightside = 0 for i in range(lon): p = m[i] if i == 0 and p == "F": Turnright += 1 elif p == "F": if m[i-1] == "L": Turnleft += 1 if m[i-1] == "R": Turnright += 1 if m[i-1] == "U": Up += 1 if m[i-1] == "D": Down += 1 if m[i-1] == "X": Leftside += 1 if m[i-1] == "Y": Rightside += 1 x = Turnright - Turnleft y = Up - Down z = Leftside - Rightside print(x, y, z)If anyone can fix the code for me, I appreciate it.
TASK LINK