Now let's test if the clicked word is in the list of strong passwords. If it is we'll add a point.

  • Go to and drag If In inside the click event. Make sure it has a green block ···· in front of it.
  • The variable before in to pw_text. Change the list after in to strong_pws.
  • Got to and use Add to a Variable to add 1 to score. Make sure it has ········ in front of it.
  • Go to and use Update Display to update score_board with the new value of score.

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", "123456", "hello1", "snuffles", "emma2003"] strong_pws = ["GgbvTa581!@", "@Mjrc0olguy!", "007jmSB0nd!", "108turt!es762", "Avv3SoMe!305"] all_pws = strong_pws + weak_pws password = codesters.Text("password", 100, 200, "red") def interval(): 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, 3) def click(sprite): global score pw_text = password.get_text() if pw_text in weak_pws: score -= 1 score_board.update(score) password.event_click(click)
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)