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.
input()
takes in one line of input, solines
simply equals"4"
for the first test case. Instead oflines.splitlines()
, you can do something likelines = [input() for _ in range(n)]
. This works because each word is on a separate line.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
andExit code is 1
) are not easy to understand or informative enough. Custom invocation gives more details, likeFile "program.pys3", line 3, in <module> n = int(l[1]) IndexError: list index out of range
include
using namespace std;
int main(){
}
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...
Use markdown and put your code in a spoiler plz bro...
And, actually I didn't understand what you're asking...