Explanation of the Solution | Text without multiple spaces

3. Katas

To see full version of Solution visit GitHub. See below↓

Solution:

  1. The first function:
    • Create a function with two variables to enter (the text you want to write and the file to write), which will write the text to the file.
    • In the function:
      • Open the file for writing.
      • Write down the text.
      • Close the file for writing.
  2. The second function:
    • Create a function with one variable to enter (file), which will remove multiple spaces.
    • In the function:
      • Open the file.
      • Create a variable for words in the form of an empty dictionary.
      • We run through all the lines of the file.
      • We run through all the words of the line.
      • Adding a word to the list for words.
      • Create a variable in which we immediately add all words from the list for words in the form of a string.
      • Close the file.
      • Return a string with all the words.
  3. Create variables for files:
    • The file from which we read the text.
    • The file into which we write the text.
  4. Main part:
    • We get a string with words from the first file using the function.
    • We add a line that we got to a file for writing to a function that writes to a file.

That's all.

If you liked Katas, you can put star on this repositories, this will motivate me to write similar Katas for you.

Visit Github page: