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
passwordvariable should be empty. Add this line to your code:
-
You want to choose a random character 10 times. To do this, add the following code:

-
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.

-
You need to use
+=to add the new character to the password each time.
-
Test your new code and you should see a password that’s 10 characters long.
