input: Write a function to generate a Random Password of length 8 characters, which contains at least one of each character type (lowercase, uppercase, digits, special characters). If the function cannot generate such a password within 1000 iterations, return "N/A".
  assert generate_password()==True
  assert generate_password()==True
  assert generate_password()==True
  assert generate_password()==True
  assert generate_password()==True
output: import random
  import string
  
  def generate_password():
      lowercase = string.ascii_lowercase
      uppercase = string.ascii_uppercase
      digits = string.digits
      special_chars = string.punctuation
      
      for _ in range(1000):
          password = [
              random.choice(lowercase),
              random.choice(uppercase),
              random.choice(digits),
              random.choice(special_chars)
          ]
          password += random.choices(lowercase + uppercase + digits + special_chars, k=4)
          random.shuffle(password)
          password = ''.join(password)
          
          if (any(c in lowercase for c in password) and
              any(c in uppercase for c in password) and
              any(c in digits for c in password) and
              any(c in special_chars for c in password)):
              return password
      
      return "N/A"