+ 21

[CHALLENGE] Replace Words in a Sentence

The challenge is to take input from the user and replace some specific word with another word as input by the user Input: I like this app.This is fun. Word to be replaced : this To be replaced with : Sololearn Output : I like Sololearn app.Sololearn is fun. Edit: Inbuit functions not allowed! (Like replace( ) ) All languages are welcome. Happy Coding!

20th Jan 2018, 4:17 PM
Abhishek Tandon
Abhishek Tandon - avatar
26 ответов
21st Jan 2018, 3:09 AM
StoneCoder🇬🇦
StoneCoder🇬🇦 - avatar
22nd Jan 2018, 1:29 PM
Prabha_I
Prabha_I - avatar
+ 15
Python should be excluded from this competition ;) print(input().replace(input(),input()))
20th Jan 2018, 4:22 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
20th Jan 2018, 6:41 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 10
Py~ print(input().replace(x, y)) #where x is word to be replace and y is the new word
20th Jan 2018, 4:21 PM
Yash✳️
Yash✳️ - avatar
+ 10
@infinity It will work for the word This.. But if you want to make it work for 'this' you can do that too print(input().lower().replace(input().lower(), input())) Python still rocks :-}
20th Jan 2018, 5:37 PM
Yash✳️
Yash✳️ - avatar
+ 9
I have edited it! Enjoy!
21st Jan 2018, 5:09 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 8
@dim_knp replace() function not allowed!!
21st Jan 2018, 6:13 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 7
@SQrL Hey! We are not anti-python...! it is just because its too easy to do it with inbuilt functions... Wait! Let me edit this question and you can answer in python as well...!
21st Jan 2018, 5:07 AM
Abhishek Tandon
Abhishek Tandon - avatar
21st Jan 2018, 3:28 PM
Vladislav Tikhiy (SILENT)
Vladislav Tikhiy (SILENT) - avatar
+ 6
You could have tried python as well as I have edited the question
21st Jan 2018, 6:12 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 6
@Infinity you want user to input the original text, the word to change and the new word, correct? And are you expecting a replacement of a single occurrence or every occurrence?
23rd Jan 2018, 8:31 AM
SQrL
SQrL - avatar
+ 5
20th Jan 2018, 5:54 PM
Hrishikesh Kulkarni
Hrishikesh Kulkarni - avatar
+ 5
Here’s my Ruby solution in 8 lines https://code.sololearn.com/cKHLNox1aX2q/?ref=app Edit: moving python to a new response
21st Jan 2018, 6:11 AM
SQrL
SQrL - avatar
+ 5
@Rohullah Yes off course! Not only me but everyone is! But first start the C++ tutorial here and post your doubts... We all will help you out!
21st Jan 2018, 12:37 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 5
good one, i will do
21st Jan 2018, 2:53 PM
SAKSHI
SAKSHI - avatar
+ 5
@Infinity Hope this one works for C#. Took me some time to fix all the bugs. https://code.sololearn.com/cyPKzU5zir1m/#cs
21st Jan 2018, 10:19 PM
dim_knp
dim_knp - avatar
23rd Jan 2018, 11:18 AM
SQrL
SQrL - avatar
+ 4
Just because PY makes it simple it’s time to hate on it?!? It’s not a ball player on roids; it’s a legitimate language
21st Jan 2018, 5:04 AM
SQrL
SQrL - avatar