count how many letter occurrences there are in a string (in ruby)
Your code is here-
- dna1 = ('ATTGCC')
- W= dna1.count('A') //letter occurrences count function
- X= dna1.count('T')
- Y= dna1.count('G')
- Z= dna1.count('C')
- puts "{"+ "'A'=>" + "#{W}"+ "," + "'T'=>" + "#{X}" + "," +"'G'=>" + "#{Y}" +"," + "'C'=>" + "#{Z}" + "}"
screenshot of output-
Comments
Post a Comment