input: 
  from typing import List
  import string
  import random
  
  def generate_password(length: int) -> str:
      """ Generates a random password of given length, which consists of alphanumeric characters and at least one special character.
      >>> generate_password(8)
      'A1b!cD2e'
      >>> generate_password(10)
      'X3y@Z4z#W5'
      >>> generate_password(6)
      'aB1!c2'
      """
      chars = string.ascii_letters + string.digits + string.punctuation
      password = ''.join(random.choice(chars) for _ in range(length))
      
      # Check if at least one special character exists in the password
      if any([char in string.punctuation for char in password]):
          return password
      else:
          return generate_password(length)
  
  print(generate_password(8))
  
output:     while True:
          password = ''.join(random.choice(chars) for _ in range(length))
          if any(char in string.punctuation for char in password):
              return password