code: def string_to_num(s: str):
      
      if isinstance(s, (int, float)):
          return s
      if s.isdigit():
          return int(s)
      try:
          return float(s)
      except ValueError:
          return None
docs: Converts a string to an int/float
  
      Returns ``None`` if it can't be converted
  
      >>> string_to_num('5')
      5
      >>> string_to_num('5.2')
      5.2
      >>> string_to_num(10)
      10
      >>> string_to_num(10.1)
      10.1
      >>> string_to_num('this is not a string') is None
      True