From 2b235f8c1d6d3ecd54bc2747ea39454b34abedb7 Mon Sep 17 00:00:00 2001 From: lazargugleta Date: Fri, 27 Sep 2019 09:07:25 +0200 Subject: [PATCH 1/3] add n_times_string snippet --- README.md | 23 +++++++++++++++++++++++ snippet_data/snippetList.json | 15 +++++++++++++++ snippet_data/snippets.json | 20 ++++++++++++++++++++ snippets/n_times_string.md | 19 +++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 snippets/n_times_string.md diff --git a/README.md b/README.md index d525798d3..7e5d8a266 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ * [`decapitalize`](#decapitalize) * [`is_anagram`](#is_anagram) * [`kebab`](#kebab) +* [`n_times_string`](#n_times_string) * [`palindrome`](#palindrome) * [`snake`](#snake) * [`split_lines`](#split_lines) @@ -1787,6 +1788,28 @@ kebab('AllThe-small Things'); # "all-the-small-things"
[⬆ Back to top](#contents) +### n_times_string + +Prints out the same string a defined number of times. + +Use this method to print out the same string n number of times. + + +```py +def n_times_string(string,n): + return (string * n) +``` + +
+Examples + +```py +n_times_string('py', 4) #'pypypypy' +``` +
+ +
[⬆ Back to top](#contents) + ### palindrome Returns `True` if the given string is a palindrome, `False` otherwise. diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index a56b243cd..165ba1244 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -807,6 +807,21 @@ "hash": "c920b58f01c63346e65eab83a60c4635d4c104e41767b9d41ad94029e662b902" } }, + { + "id": "n_times_string", + "type": "snippetListing", + "title": "n_times_string", + "attributes": { + "text": "Prints out the same string a defined number of times.\n\nUse this method to print out the same string n number of times.\n\n\n", + "tags": [ + "string", + "beginner" + ] + }, + "meta": { + "hash": "2d7a8e4505e3ad18e72464fa91c6bfe78592a5873c6202c0758b00f6daf11f8a" + } + }, { "id": "none", "type": "snippetListing", diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index d6d6078e9..2dc6ab0a2 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -1067,6 +1067,26 @@ "hash": "c920b58f01c63346e65eab83a60c4635d4c104e41767b9d41ad94029e662b902" } }, + { + "id": "n_times_string", + "title": "n_times_string", + "type": "snippet", + "attributes": { + "fileName": "n_times_string.md", + "text": "Prints out the same string a defined number of times.\n\nUse this method to print out the same string n number of times.\n\n\n", + "codeBlocks": { + "code": "def n_times_string(string,n):\r\n return (string * n)", + "example": "n_times_string('py', 4) #'pypypypy'" + }, + "tags": [ + "string", + "beginner" + ] + }, + "meta": { + "hash": "2d7a8e4505e3ad18e72464fa91c6bfe78592a5873c6202c0758b00f6daf11f8a" + } + }, { "id": "none", "title": "none", diff --git a/snippets/n_times_string.md b/snippets/n_times_string.md new file mode 100644 index 000000000..8fe23ae80 --- /dev/null +++ b/snippets/n_times_string.md @@ -0,0 +1,19 @@ +--- +title: n_times_string +tags: string,beginner +--- + +Prints out the same string a defined number of times. + +Use this method to print out the same string n number of times. + + +```py +def n_times_string(string,n): + return (string * n) +``` + +```py +n_times_string('py', 4) #'pypypypy' + +``` From fb491879f6cc1f86d53879383c464f6b713a3d06 Mon Sep 17 00:00:00 2001 From: lazargugleta Date: Fri, 27 Sep 2019 09:39:22 +0200 Subject: [PATCH 2/3] add n_times_string snippet --- README.md | 4 ++-- snippet_data/snippetList.json | 2 +- snippet_data/snippets.json | 4 ++-- snippets/n_times_string.md | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7e5d8a266..1e318f953 100644 --- a/README.md +++ b/README.md @@ -1796,8 +1796,8 @@ Use this method to print out the same string n number of times. ```py -def n_times_string(string,n): - return (string * n) +def n_times_string(str,n): + return (str * n) ```
diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index 165ba1244..691a7a121 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -819,7 +819,7 @@ ] }, "meta": { - "hash": "2d7a8e4505e3ad18e72464fa91c6bfe78592a5873c6202c0758b00f6daf11f8a" + "hash": "b8ba27a04a5c2dcd91f6643eb02b61b9df9a58bedea26ceb2042cb535c0c1eb1" } }, { diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index 2dc6ab0a2..a4df75ffb 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -1075,7 +1075,7 @@ "fileName": "n_times_string.md", "text": "Prints out the same string a defined number of times.\n\nUse this method to print out the same string n number of times.\n\n\n", "codeBlocks": { - "code": "def n_times_string(string,n):\r\n return (string * n)", + "code": "def n_times_string(str,n):\r\n return (str * n)", "example": "n_times_string('py', 4) #'pypypypy'" }, "tags": [ @@ -1084,7 +1084,7 @@ ] }, "meta": { - "hash": "2d7a8e4505e3ad18e72464fa91c6bfe78592a5873c6202c0758b00f6daf11f8a" + "hash": "b8ba27a04a5c2dcd91f6643eb02b61b9df9a58bedea26ceb2042cb535c0c1eb1" } }, { diff --git a/snippets/n_times_string.md b/snippets/n_times_string.md index 8fe23ae80..8cc40a50e 100644 --- a/snippets/n_times_string.md +++ b/snippets/n_times_string.md @@ -9,8 +9,8 @@ Use this method to print out the same string n number of times. ```py -def n_times_string(string,n): - return (string * n) +def n_times_string(str,n): + return (str * n) ``` ```py From 0d84ca0c8b7bbcd867e599da287781f69ec3d171 Mon Sep 17 00:00:00 2001 From: lazargugleta Date: Fri, 27 Sep 2019 14:05:46 +0200 Subject: [PATCH 3/3] fix minor issues with n_times_string --- snippets/n_times_string.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/snippets/n_times_string.md b/snippets/n_times_string.md index 8cc40a50e..7dcf79791 100644 --- a/snippets/n_times_string.md +++ b/snippets/n_times_string.md @@ -5,8 +5,7 @@ tags: string,beginner Prints out the same string a defined number of times. -Use this method to print out the same string n number of times. - +Repeat the string `n` times, using the `*` operator. ```py def n_times_string(str,n): @@ -16,4 +15,4 @@ def n_times_string(str,n): ```py n_times_string('py', 4) #'pypypypy' -``` +``` \ No newline at end of file