input: Write a function to generate a random string of length 8 made of uppercase letters and numbers. If the input length is not provided, the function should default to 8. If the input length is provided, the function should generate a string of that length. The function should return the generated string.
  import string
  import random
  
  def generate_random_string(length=8):
      chars = string.ascii_uppercase + string.digits
      return ''.join(random.choice(chars) for i in range(length))
  
  assert generate_random_string()=="A3B5C7D9"
  assert generate_random_string(10)=="E1F2G3H4I5"
  assert generate_random_string(6)=="K6L7M8"
  assert generate_random_string(8)=="N9O0P1Q2"
  assert generate_random_string(4)=="R3S4"
output: import string
  import random
  
  def generate_random_string(length=8):
      chars = string.ascii_uppercase + string.digits
      return ''.join(random.choice(chars) for i in range(length))