Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60945
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Subject | Re: The input and output is as wanted, but why error? |
| Date | 2013-12-03 16:10 +0000 |
| Organization | Norwich University |
| References | <387f5b5f-faf1-4715-8d49-e366be53fd00@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3518.1386087064.18130.python-list@python.org> (permalink) |
On 2013-12-03, geezle86@gmail.com <geezle86@gmail.com> wrote: > I am trying to solve this problem: > > http://codeforces.com/problemset/problem/71/A Please post your code in and the problem in your message. Here it is for those reading along: > A. Way Too Long Words > Sometimes some words like "localization" or > "internationalization" are so long that writing them many times > in one text is quite tiresome. > > Let's consider a word too long, if its length is strictly more > than 10 characters. All too long words should be replaced with > a special abbreviation. > > This abbreviation is made like this: we write down the first > and the last letter of a word and between them we write the > number of letters between the first and the last letters. That > number is in decimal system and doesn't contain any leading > zeroes. > > Thus, "localization" will be spelt as "l10n", and > "internationalization» will be spelt as "i18n". This is a ridiculous abbreviation scheme, but for purposes of your project that doesn't matter. > You are suggested to automatize the process of changing the > words with abbreviations. At that all too long words should be > replaced by the abbreviation and the words that are not too > long should not undergo any changes. > > Input > The first line contains an integer n (1?=?n?=?100). Each of the > following n lines contains one word. All the words consist of > lowercase Latin letters and possess the lengths of from 1 to > 100 characters. > > Output > Print n lines. The i-th line should contain the result of > replacing of the i-th word from the input data Here's your solution so far: > x = input() > > if x.isdigit() == False: > i = len(x) > j = i - 1 > k = i - 2 > > xList = list(x) > > if len(xList) > 4: > print(xList[0], int(k), xList[j], sep='', end='') > else: > print(x) > else: > SystemExit > > The input and output is as wanted, but my answer keep rejected, > here is my source code http://txt.do/1smv No, your program outputs nothing. That's bound to fail. ;) How is your program supposed to work, in your own words? -- Neil Cerutti
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 07:48 -0800
Re: The input and output is as wanted, but why error? John Gordon <gordon@panix.com> - 2013-12-03 16:03 +0000
Re: The input and output is as wanted, but why error? Neil Cerutti <neilc@norwich.edu> - 2013-12-03 16:10 +0000
Re: The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 08:35 -0800
Re: The input and output is as wanted, but why error? Dave Angel <davea@davea.name> - 2013-12-03 12:58 -0500
Re: The input and output is as wanted, but why error? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-03 17:54 -0500
Re: The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 08:36 -0800
Re: The input and output is as wanted, but why error? Neil Cerutti <neilc@norwich.edu> - 2013-12-03 16:58 +0000
Re: The input and output is as wanted, but why error? geezle86@gmail.com - 2013-12-03 08:38 -0800
Re: The input and output is as wanted, but why error? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-03 16:51 +0000
Re: The input and output is as wanted, but why error? rusi <rustompmody@gmail.com> - 2013-12-03 09:19 -0800
Re: The input and output is as wanted, but why error? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-03 23:52 +0000
csiph-web