input: Write a function to generate a random password with a length of 8 characters, consisting of at least one uppercase letter, one lowercase letter, one digit, and one special character.
  assert generate_password()=="A1b@C3d#"
  assert generate_password()=="X2y!Z4w$"
  assert generate_password()=="Q3r@T5e%"
  assert generate_password()=="J6k!L7m#"
  assert generate_password()=="P8o@N9i$"
output: import random
  import string
  
  def generate_password():
      while True:
          password = ''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=8))
          if (any(c.isupper() for c in password) and
              any(c.islower() for c in password) and
              any(c.isdigit() for c in password) and
              any(c in string.punctuation for c in password)):
              return password