code: def name2taxid(taxids, ncbi):
      
      new_taxids = []
      for taxid in taxids:
          try:
              new_taxids.append(ncbi.get_name_translator([taxid])[taxid][0])
          except KeyError:
              try:
                  new_taxids.append(int(taxid))
              except ValueError:
                  msg = 'Error: cannot convert to taxid: {}'
                  raise ValueError(msg.format(taxid))
  
      return new_taxids
docs: Converting taxon names to taxids