STEP 4: Let's name our function!

Give functions names related to what they will do. This makes your code easier to read and use.

  • Go to and drag out Define Function. Drop it at the bottom of your program.
  • Change the name of the function from my_function to bridge_scene.
  • Drop the Drawbridge background INSIDE your function. Indent it 4 spaces under the def line.

Just like loops and conditionals, a function will cause an error if it is empty.

sprite = codesters.Sprite("knight1", -175, -150) sprite.set_speed(2) def park_scene(): stage.set_background("park") sprite.say("I should hurry to the castle!") sprite.move_forward(550) park_scene()