Python Forum

Full Version: Grok Acedemy Sport Microbit Tilt Both Ways Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, im currently doing the grok academy sport microbit course and im up to ‘Tilt Both ways’ an activity in module 5. I have cleared most of the tests besides the test thats states ‘Testing many different values.’ it said i failed that test because ‘Display was showing Image.ARROW_S.’


My Current code is as follows:
from microbit import *

while True:
  if accelerometer.get_y() > 500:
    display.show(Image.ARROW_S)
  elif accelerometer.get_y() < -500:
    display.show(Image.ARROW_N)
  if accelerometer.get_x() > 500:
    display.show(Image.ARROW_E)
  elif accelerometer.get_x() < -500:
    display.show(Image.ARROW_W)
  elif accelerometer.get_y() == 0 and accelerometer.get_x()== 0:
    display.show(Image.TARGET)
what am i doing wrong? (btw this is my first time using this website and i just copy pasted the code straight into this so the indentation isnt showing up but im fairly sure i have the correct indentaion)
should line 8 be elif as well?