+ 69

CHALLENGE: Counting And Display Strings

Write a program that captures a string that can contain spaces and displays each word in the string, the separator being the space. Example, for the input: "I think so I am" The program displays: word 1: I word 2: think word 3: so word 4: I word 5: am And finally it shows how many words the sentence has. Good luck.

14th Jan 2018, 4:33 PM
Med Arezki
Med Arezki - avatar
109 Antworten
+ 39
@med Nice basic challenge thank you pythonistas take it easy https://code.sololearn.com/cKb3je99nnwL/?ref=app
14th Jan 2018, 5:08 PM
Oma Falk
Oma Falk - avatar
16th Jan 2018, 7:38 PM
Ghena Ramascan
Ghena Ramascan - avatar
+ 33
https://code.sololearn.com/c5R1Oi6UVfB4/?ref=app
15th Jan 2018, 6:27 AM
LukArToDo
LukArToDo - avatar
15th Jan 2018, 5:21 AM
Justine Ogaraku
Justine Ogaraku - avatar
15th Jan 2018, 7:07 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 20
https://code.sololearn.com/c3wz3rzJMHOD/?ref=app
15th Jan 2018, 12:08 PM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
15th Jan 2018, 6:02 AM
noobcøder
noobcøder - avatar
16th Jan 2018, 1:21 AM
Faisal
Faisal - avatar
+ 16
// JS Solution let words = prompt("Enter something", "I think so I am").split(" "); for(var i = 0; i < words.length; i++) { document.write(`word ${i+1}: ${words[i]}<br />`); } document.write("<br />You have entered ", i, " words!");
15th Jan 2018, 2:18 PM
777
777 - avatar
+ 16
Slowly I start to think you can do everything in one line in python https://code.sololearn.com/c2EqFC663P7o/#py
16th Jan 2018, 8:36 AM
Serge Gerodes
Serge Gerodes - avatar
+ 16
https://code.sololearn.com/coTnqYEGTIeE/?ref=app
16th Jan 2018, 5:19 PM
Danijel Ivanović
Danijel Ivanović - avatar
15th Jan 2018, 10:00 AM
AZTECCO
AZTECCO - avatar
15th Jan 2018, 3:28 PM
Abhishek Tandon
Abhishek Tandon - avatar
15th Jan 2018, 9:14 AM
Ferhat Sevim
Ferhat Sevim - avatar
+ 11
My solution: Can handle multiple consecutive spaces. https://code.sololearn.com/WwrZS8v3IKDq/?ref=app
15th Jan 2018, 10:31 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 11
https://code.sololearn.com/cXJAx2Tx5rRr/?ref=app
16th Jan 2018, 6:23 AM
Marfik Em
Marfik Em - avatar
16th Jan 2018, 7:32 AM
Я. ♨
Я. ♨ - avatar
+ 11
https://code.sololearn.com/cKadiV9kgC4M/?ref=app
20th Jan 2018, 10:18 PM
Raphael Williams
Raphael Williams - avatar
16th Jan 2018, 6:57 AM
Mahdi Cheikhrouhou
Mahdi Cheikhrouhou - avatar
+ 10
Working now! thanks @Jonathan Pizarra https://code.sololearn.com/WYSEJr7k12KM/?ref=app
16th Jan 2018, 8:12 AM
StoneCoder🇬🇦
StoneCoder🇬🇦 - avatar