Hallo ...
I am very new to Python programming & I have this Question ...
I am asked to write a program to calculate the No. of words & the length of each (letters) in this sentence :
(An Oligonucleotide is a short segment of RNA or DNA, typically with twenty or fewer bases. Although they can be formed by cleavage of longer segments,
they are now more commonly synthesized by polymerizing individual nucleotide
precursors. Automated synthesizers allow the synthesis of oligonucleotides up to 160
to 200 bases) & here how I did it :
s="""An Oligonucleotide is a short segment of RNA or DNA, typically with twenty or fewer bases. Although they can be formed by cleavage of longer segments,
they are now more commonly synthesized by polymerizing individual nucleotide
precursors. Automated synthesizers allow the synthesis of oligonucleotides up to 160
to 200 bases"""
s=s.replace('\n','')
print s
a=s.split()
print "Number of words =",len(a)
for i in a :
b=len(i)
print b
My program working fine ,But I want to modify it ,& to print infront of each number ,the words that indicate its length for example :( An =2 ,oligonucleotide=15 & so ...) or i also tried to print ( the letters No.in the word No.1 =2 , the letters No. in the word No.2 =15 & so on for the rest of the 47 words)
I started to make a loop for the words no . like this
s=s.replace('\n','')
print s
a=s.split()
print "Number of words =",len(a)
for i in a :
q=0 # to creat a loop for the number of the words
while (q<48):
q+=1
b=len(i)
print "the No.of letters in word No",q,b # the statment of "the No of letters..." should be the same but with changing No .& that is what Q should point to like : 1,2,3,4,.....till 47
But it didnt work !!any possible help or hint ?