input: Write a function to generate a random string of length 8 made of uppercase letters and numbers. If the length is invalid, raise a ValueError.
  assert generate_random_string(8) in [c for c in string.ascii_uppercase + string.digits] * 8
  assert generate_random_string(7) == ValueError
  assert generate_random_string(-1) == ValueError
output: import random
  import string
  
  def generate_random_string(length):
      if length != 8:
          raise ValueError
      return ''.join(random.choices(string.ascii_uppercase + string.digits, k=length))