The input and output is as wanted, but why error?

Neil Cerutti neilc at norwich.edu
Tue Dec 3 11:10:40 EST 2013


On 2013-12-03, geezle86 at gmail.com <geezle86 at 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




More information about the Python-list mailing list