I am currently doing a python challenge in which I have to create certain codes. I am stuck on a particularly hard question and would appreciate some help. The problem is:
In 1989, a journalist asked Paul Boutin, an engineer at the Massachusetts Institue of Technology, "What do you think will be the biggest problem in computing in the 90s?" Paul replied: "There are only 17,000 three-letter acronyms."
To be precise, there are 263 = 17,576.
Write a program which takes in a TLA (a three letter abbreviation of the first letters of three words) and a line of text, and prints out all possible solutions for that TLA, all in lowercase.
An example is:
Abbreviation: TLA Text: I really think lots about python . The long afternoons I've spent tinkering with concepts and truly lovely code have been well spent . think lots about the long afternoons
So far I have the code:
a = raw_input("Abbreviation: ") a = a.lower() b = raw_input("Text: ") b = b.lower() b = b.split() c = 0 while c < len(b): d = c + 1 e = d + 1 if b[c].startswith(a): if b[d].startswith(a): if b[e].startswith(a): f = b[c] + " " + b[d] + " " + b[e] print f c = c + 1
But when I enter TLAs where the first letter is the same as the third letter, and index error comes up on line 12. I don't understand where I am going wrong and desparately need the solution. Can anyone help me?