-
-
Save TheMuellenator/dc4d84419c38a5aa023f85c26bea2dc7 to your computer and use it in GitHub Desktop.
tracker = 0 | |
def moveForwards(): | |
global tracker | |
tracker += 1 | |
print('moved forward by one step.') | |
def turnRight(): | |
global tracker | |
tracker -= 1 | |
print('turning right') | |
def move(): | |
#Solution | |
moveForwards() | |
turnRight() | |
turnRight() | |
turnRight() | |
moveForwards() | |
turnRight() | |
turnRight() | |
turnRight() | |
moveForwards() | |
turnRight() | |
moveForwards() | |
turnRight() | |
moveForwards() | |
moveForwards() | |
return tracker | |
cant you just make/trick the tracker into making negative right turns rather than the analog right(), right(), right(), until desired direction?
If you ever get stuck in coding, just ask ChatGPT; they will make the script for you and you can ask anything to explain it in detail.
wonder what its got to say about jesus taking the wheel... i know... i'll ask
for those asking about the tracker, since "moveforwards" and "turnright" does not mean anything to Python, the tracker exists to serve as a proxy test to see whether you moved forward or moved right the correct number of times.
This exersice have logical issue. We define function move() by calling two functions moveForwards() and trunRight()
BUT
we never call function move(). And this is where the logic error occure: if you only define function you pass exersice, but if you define and call it you fail test. But only defining function doesn't make move so this excersice omite important part of calling the function.
Can you please explain global function in here?