Password Generator

A random password

A single character isn’t very useful – let’s improve your program to create a longer password.

  • To create a password, you will add random characters to it, one at a time.

    To start with, your password variable should be empty. Add this line to your code:

    screenshot

  • You want to choose a random character 10 times. To do this, add the following code:

    screenshot

  • You should also indent (move in) the line to choose a random character, so that it happens 10 times.

    To indent, press the ‘tab’ key.

    screenshot

  • You need to use += to add the new character to the password each time.

    screenshot

  • Test your new code and you should see a password that’s 10 characters long.

    screenshot