Explanation of the Solution | Write and Search for products in a file
3. Katas
To see full version of Solution visit GitHub. See below↓
Solution:
-
Zero function:
- Create a function with one variable to enter (the number of products to write to the file), which write the goods to a file.
-
In the function:
- Open the file.
-
Create a loop in which:
- Enter the name of the product, country and volume.
- Add three variables to the list.
- Convert a list to a string for writing to a file.
- Adding a line to the file.
- Close the file.
- Return the name of the file to which all are recorded for further action with it.
- Add a variable to which after starting the program will write the number of products to add to the file.
- We create another variable in which we call our function with the previous variable.
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: