input: from typing import List
  
  def generate_password(length: int = 8) -> str:
      """ Generates a random password of given length, which consists of alphanumeric characters and at least one special character.
      >>> print(generate_password())
      'A1b2@c3d'
      >>> print(generate_password(12))
      'X9Y8!z7W6#v5'
      """
      import string
      import random
  
      chars = string.ascii_letters + string.digits + string.punctuation
  
      while True:
          password = ''.join(random.choice(chars) for _ in range(length))
          if any([char in string.punctuation for char in password]):
              return password
          else:
              continue
output:     import string
      import random
  
      chars = string.ascii_letters + string.digits + string.punctuation
  
      while True:
          password = ''.join(random.choice(chars) for _ in range(length))
          if any([char in string.punctuation for char in password]):
              return password
          else:
              continue