code: def range_span(ranges):
      
      if not ranges:
          return 0
  
      ranges.sort()
      ans = 0
      for seq, lt in groupby(ranges, key=lambda x: x[0]):
          lt = list(lt)
          ans += max(max(lt)[1:]) - min(min(lt)[1:]) + 1
      return ans
docs: Returns the total span between the left most range to the right most range.
  
      >>> ranges = [("1", 30, 45), ("1", 40, 50), ("1", 10, 50)]
      >>> range_span(ranges)
      41
      >>> ranges = [("1", 30, 45), ("2", 40, 50)]
      >>> range_span(ranges)
      27
      >>> ranges = [("1", 30, 45), ("1", 45, 50)]
      >>> range_span(ranges)
      21
      >>> range_span([])
      0