input: Write a function to generate a random password. The password should have a minimum length of 8 characters and must contain at least one number and one special character. If no length is specified, the default length should be 8.
  
  def generate_password(length=8):
      import string
      import random
      chars = string.ascii_letters + string.digits + string.punctuation
      password = "".join(random.choice(chars) for _ in range(length))
      while not (any(char.isdigit() for char in password) and any(char in string.punctuation for char in password)):
          password = "".join(random.choice(chars) for _ in range(length))
      return password
  
  assert len(generate_password()) >= 8
  assert any(char.isdigit() for char in generate_password())
  assert any(char in string.punctuation for char in generate_password())
  assert len(generate_password(10)) == 10
  assert any(char.isdigit() for char in generate_password(10))
  assert any(char in string.punctuation for char in generate_password(10))
output: def generate_password(length=8):
      import string
      import random
      chars = string.ascii_letters + string.digits + string.punctuation
      password = "".join(random.choice(chars) for _ in range(length))
      while not (any(char.isdigit() for char in password) and any(char in string.punctuation for char in password)):
          password = "".join(random.choice(chars) for _ in range(length))
      return password