DNA Analysis: best choice for string formatting ... %s or %d?


for the DNA analysis project, the method is_criminal uses %s for string formatting:

def is_criminal(dna_sample):
  dna_data = read_dna(dna_sample)
  codons = dna_codons(dna_data)
  num_matches = match_dna(codons)
  if num_matches > 3:
    print "number of codon matches: %s. continue investigation!" % num_matches
    print "number of codon matches: %s. suspect is free to go!" % num_matches

but shouldn't %d be used instead, given that num_matches is an integer?
or how about str(num_matches)?

note that the above code also works if %d or str(num_matches) is used



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.