Let's test if the clicked word is in the list of weak passwords. If it is a weak password, let's subtract 1 point.

  • Go to and drag out If In and drop it inside the click event.
  • The variable before in to pw_text. Change the list after in to weak_pws.
  • Go to and drag out Subtract from Variable. Drop it inside of the new if statement.
  • Change the name of the variable to score. Make sure that it has two blocks ········ in front of it.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("underwater") score = 0 score_board = codesters.Display(score) weak_pws = ["password", "password123", "hello1", "snuffles", "123456"] strong_pws = ["GgbvTa581!@", "@Mjrc0olguy!", "007jmSB0nd!", "108turt!es762", "Avv3SoMe!305"] all_pws = weak_pws + strong_pws # text = codesters.Text("text", x, y, "color") password = codesters.Text("password", 100, 200, "red") def interval(): # add any other actions... rand_x = random.randint(-225, 225) rand_y = random.randint(-225, 225) rand_pw = random.choice(all_pws) password.set_text(rand_pw) password.go_to(rand_x, rand_y) stage.event_interval(interval, 2) def click(sprite): global score pw_text = password.get_text() # add other actions... password.event_click(click)
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)