help with optional reading think python exercise 8.2. How do I slice and insert new dna into a string and splice it back together again? code attached: #http://www.greenteapress.com/thinkpython/thinkpython.pdf #chapter 8 for loops #brandon MOOC group 3 #oct. 20 prefixes = 'JKLMNOPQ' suffix = 'ack' news=[] for letter in prefixes: news.append( letter + suffix) print news for each word in news if [:1] == 'O': #finds Oack in the list #code to mutate Oack to Ouack elif [:1] == "Q": #finds Qack in the list #code to insert u before ack

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

help with optional reading think python exercise 8.2. How do I slice and insert new dna into a string and splice it back together again? code attached: #http://www.greenteapress.com/thinkpython/thinkpython.pdf #chapter 8 for loops #brandon MOOC group 3 #oct. 20 prefixes = 'JKLMNOPQ' suffix = 'ack' news=[] for letter in prefixes: news.append( letter + suffix) print news for each word in news if [:1] == 'O': #finds Oack in the list #code to mutate Oack to Ouack elif [:1] == "Q": #finds Qack in the list #code to insert u before ack

MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

Like this ? prefixes = 'JKLMNOPQ' suffix = 'ack' news=[] for letter in prefixes: if letter == 'O' or letter == 'Q': letter += 'u' news.append( letter + suffix) print news
Btw, if you really want to "insert" a char into a String, as strings are immutable, you should probably do like this : word = word[0] + 'u' + word[1:], but then you have to replace the word in the list : for index, word in enumerate(news): if word[0] in ['O', 'Q']: word = word[0] + 'u' + word[1:] news[index] = word print news
Since you've already put it into a list, I would opt to use the list splice method... for i in range(0, len(news)): letter=news[i][:1] if letter=='O'or letter=='Q': news[i]=news[i][:1]+'u'+news[i][1:] As @FabienToune put it, you will need to replace the word after changing it.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question