input: Write a python function to generate a random password of specified length containing at least one lowercase letter, one uppercase letter, one digit, and one special character.
  assert len(generate_password(10)) == 10
  assert any(char.islower() for char in generate_password(15))
  assert any(char.isupper() for char in generate_password(15))
  assert any(char.isdigit() for char in generate_password(15))
  assert any(char in string.punctuation for char in generate_password(15))
output: import random
  import string
  
  def generate_password(length):
      if length < 4:
          raise ValueError("Password length must be at least 4 characters")
  
      all_chars = string.ascii_letters + string.digits + string.punctuation
      password = [
          random.choice(string.ascii_lowercase),
          random.choice(string.ascii_uppercase),
          random.choice(string.digits),
          random.choice(string.punctuation)
      ]
  
      password += random.choices(all_chars, k=length - 4)
      random.shuffle(password)
      
      return ''.join(password)