Standard library · 11 / 17 Exercise Medium

Password generator

Objective

Create a Python program that generates a random password with the random and string modules.

Instructions

  • Import the random and string modules.
  • Read the length n of the password.
  • Build the set of allowed characters by joining string.ascii_letters (letters) and string.digits (digits).
  • Generate the password by choosing n random characters with random.choice.
  • Since it is random, do not show it. Show Length: n on the first line and Alphanumeric: V on the second, where V is the result of isalnum() on the password.
Input
8
Output
Length: 8
Alphanumeric: True

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise