input: Write a function to generate a password string of specified length containing random alphabets, numbers, and special characters.
  assert len(generate_password(10)) == 10
  assert len(generate_password(15)) == 15
  assert any(char.isdigit() for char in generate_password(8))
  assert any(char.isalpha() for char in generate_password(8))
  assert any(char in string.punctuation for char in generate_password(8))
output: import random
  import string
  
  def generate_password(length):
      if length < 1:
          return ''
          
      all_characters = string.ascii_letters + string.digits + string.punctuation
      password = ''.join(random.choice(all_characters) for _ in range(length))
      
      # Ensure password contains at least one digit, one letter, and one special character
      while (not any(char.isdigit() for char in password) or
             not any(char.isalpha() for char in password) or
             not any(char in string.punctuation for char in password)):
          password = ''.join(random.choice(all_characters) for _ in range(length))
      
      return password