+ 22

[ASSIGNMENT] 🚩🚩 Add ! And ?? In Spaces

Write a program to accept user's input with spaces. If there is a single space in that input, add ! sign . If there are 2 spaces, add ?? sign. Example: Input:abc de feg Output: abc!de??feg Input: I love Sololearn Output: I!love?? Sololearn You can use any languages Note: I also submitted this challenge to Lesson Factory😉

17th Mar 2018, 4:36 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
14 Answers
+ 14
For some reason, this occasionally says compilation error on Code Playground. https://code.sololearn.com/cF3s29Qem3Jg/?ref=app
17th Mar 2018, 5:24 AM
Hatsy Rei
Hatsy Rei - avatar
+ 23
https://code.sololearn.com/cJ2ixOBJNuKa/?ref=app
17th Mar 2018, 7:37 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 19
For some reason, this occasionally says compilation error in Code Playground. https://code.sololearn.com/cLX0xixfJ7tY/?ref=app
17th Mar 2018, 6:18 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 16
https://code.sololearn.com/cCSDzrX2QOw6/?ref=app
17th Mar 2018, 12:14 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 14
alert(prompt().replace(' ', '??').replace(' ', '!'))
17th Mar 2018, 5:47 AM
Kartikey Sahu
Kartikey Sahu - avatar
+ 8
Python: print(input().replace(“ “, “??”).replace(“ “, “!”))
17th Mar 2018, 4:23 PM
Pedro Demingos
Pedro Demingos - avatar
17th Mar 2018, 11:55 PM
Med Arezki
Med Arezki - avatar
+ 7
https://code.sololearn.com/cKnxQGmvySWg/?ref=app
18th Mar 2018, 4:04 AM
VISHAL SRIVASTAVA
VISHAL SRIVASTAVA - avatar
17th Mar 2018, 7:28 AM
Jonas Schröter
Jonas Schröter - avatar
17th Mar 2018, 9:32 PM
Tomás Badenes
Tomás Badenes - avatar
+ 5
[edit: this is fixed] [meta, temporary] I've ID'd the thing giving the Compilation Error and reported with feedback. if you get the error and your code usually runs, just run again.
18th Mar 2018, 2:08 AM
Kirk Schafer
Kirk Schafer - avatar
+ 4
https://code.sololearn.com/c6l4ciKr4ePe/#py using regular expression functions #python
17th Mar 2018, 10:07 AM
Pallav Gurung
+ 3
function format(input){ var output = input.replace(/\s{2}/g, "??").replace(/\s{1}/g, "!"); return output; } console.log(format("I love Sololearn.")); // logs "I??love!Sololearn." console.log(format("abc de feg")); // logs "abc!de??feg" or short console.log("I love Sololearn.".replace(/\s{2}/g, "??").replace(/\s{1}/g, "!")); // logs "I??love!Sololearn."
17th Mar 2018, 5:15 AM
Vikash Pal
Vikash Pal - avatar