### parkershamblin's blog

By parkershamblin, history, 2 years ago,

Hi, this is my first day on Codeforces and I'm currently struggling to get started. Here is the link to the problem I am trying to solve: https://codeforces.com/problemset/problem/71/A

I am not sure why my submission keeps failing on test 1.

lines = input()
lines = lines.splitlines()
n = int(lines[0])

for word in lines[1:n+1]:
if len(word) > 10:
abrv = f"{word[0]}{len(word[1:-1])}{word[-1]}"
print(abrv)
else:
print(word)


Does anyone have any ideas?

Thanks, Parker.

• -10

| Write comment?
 » 2 years ago, # |   0 input() takes in one line of input, so lines simply equals "4" for the first test case. Instead of lines.splitlines(), you can do something like lines = [input() for _ in range(n)]. This works because each word is on a separate line.
 » 2 years ago, # |   0 Just a useful hint: you can use custom invocation tab to check how your solution runs on Codeforces server. Sometimes checker error that you can see in the submission page (like in your case wrong output format Unexpected end of file - token expected and Exit code is 1) are not easy to understand or informative enough. Custom invocation gives more details, like File "program.pys3", line 3, in n = int(l[1]) IndexError: list index out of range
 » 2 years ago, # |   0 w = str(input()) def Division(x): if len(x)<= 10: print(x) else: first = x[0] last = x[-1] lenght = len(x[1:-1]) print(f"{first}{lenght}{last}")Division(w)Here is my code to but am getting wrong answers but in my test cases in terminal it works fine
•  » » 2 months ago, # ^ | ← Rev. 2 →   0 nevermind i just fixed the code. Turns out the number is actually the amount of words you want to input. My dumbass just didn't understand the queston properly. The questions themselves are harder to understand than actually solving it smh
»
21 month(s) ago, # |
Rev. 3   0
Spoiler

input code:

2 aaaabbbbbbcc a10c word word

what if i want to write the output is:

2 aaaabbbbbbcc word

output: a10c word

Do I need structure here?And how can I write the code?Thanks...

•  » » 21 month(s) ago, # ^ | ← Rev. 4 →   0 Use markdown and put your code in a spoiler plz bro... Like this#include using namespace std; int main(){ int n; cin >> n; while( n-- ){ string s; cin >> s; int l = s.length(); if( l > 10 ) cout << s[0] << l-2 << s[l-1] << endl; else cout << s << endl; } return 0; And, actually I didn't understand what you're asking...