[Challenge]String shortener | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

[Challenge]String shortener

Taking a string and an integer as an argument build a program that make the string short with "..." at the end of it. And the formatted string's length should be the int arg that provided eg: input:- sololearn is great 14 output:- sololearn is...

10th Jun 2018, 7:33 AM
Seniru
Seniru - avatar
9 Answers
+ 9
Python: print(input()[:int(input())] + "...") https://code.sololearn.com/cyJtJ8WfEtOF/?ref=app
10th Jun 2018, 8:05 AM
David Ashton
David Ashton - avatar
10th Jun 2018, 3:27 PM
Shobikaj
Shobikaj - avatar
+ 3
First Challenge I took on, also I'm not too sure how people post their code but I hope this works: https://code.sololearn.com/c8NAiz5Xp6Ed/#py
13th Jun 2018, 3:59 AM
Roberto Gomez
Roberto Gomez - avatar
+ 3
https://code.sololearn.com/clwhknDF2GQK/?ref=app
23rd Sep 2018, 2:25 PM
...
+ 1
Javascript: const shortener = (s,n) => s.substr(0,n) + '...'; alert(shortener('sololearn is great', 12)); https://code.sololearn.com/WWqZXyGe58xS/?ref=app
10th Jun 2018, 7:40 AM
Calviղ
Calviղ - avatar
+ 1
Арман Арманов я не знаю
10th Jun 2018, 9:45 AM
Calviղ
Calviղ - avatar
+ 1
10th Jun 2018, 5:06 PM
Ige Li
Ige Li - avatar
0
очем они толкуют?
10th Jun 2018, 9:40 AM
Арман Арманов
Арман Арманов - avatar
0
Thank you all for commenting here. Here is my try in Java https://code.sololearn.com/c24I2Pq1eim0/?ref=app
10th Jun 2018, 1:33 PM
Seniru
Seniru - avatar