input: 
  import random
  
  def generate_password(string: str, length: int) -> str:
      """ Generate a random password of a specified length from a given set of characters.
      >>> generate_password("abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?", 8)
      'hY7x2J9w'
      >>> generate_password("abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?", 12)
      'Q3v5a@8p9kXe'
      """
      return "".join(random.sample(string, length))
  
output:     return "".join(random.choices(string, k=length))