code: def ground_state_term_symbol(self):
          
          L_symbols = 'SPDFGHIKLMNOQRTUVWXYZ'
  
          term_symbols = self.term_symbols
          term_symbol_flat = {term: {"multiplicity": int(term[0]),
                                     "L": L_symbols.index(term[1]),
                                     "J": float(term[2:])}
                              for term in sum(term_symbols, [])}
  
          multi = [int(item['multiplicity'])
                   for terms, item in term_symbol_flat.items()]
          max_multi_terms = {symbol: item
                             for symbol, item in term_symbol_flat.items()
                             if item['multiplicity'] == max(multi)}
  
          Ls = [item['L'] for terms, item in max_multi_terms.items()]
          max_L_terms = {symbol: item
                         for symbol, item in term_symbol_flat.items()
                         if item['L'] == max(Ls)}
  
          J_sorted_terms = sorted(max_L_terms.items(),
                                  key=lambda k: k[1]['J'])
          L, v_e = self.valence
          if v_e <= (2 * L + 1):
              return J_sorted_terms[0][0]
          else:
              return J_sorted_terms[-1][0]
docs: Ground state term symbol
          Selected based on Hund's Rule