Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8ef329

Browse files
Add string utility functions: count vowels, check anagram, and remove punctuation
1 parent 2cdd003 commit a8ef329

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎public/data/python.json‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,48 @@
2828
],
2929
"tags": ["python", "string", "palindrome", "utility"],
3030
"author": "dostonnabotov"
31+
},
32+
{
33+
"title": "Count Vowels",
34+
"description": "Counts the number of vowels in a string.",
35+
"code": [
36+
"def count_vowels(s):",
37+
" vowels = 'aeiouAEIOU'",
38+
" return len([char for char in s if char in vowels])",
39+
"",
40+
"# Usage:",
41+
"print(count_vowels('hello')) # Output: 2"
42+
],
43+
"tags": ["python", "string", "vowels", "count", "utility"],
44+
"author": "SteliosGee"
45+
},
46+
{
47+
"title": "Check Anagram",
48+
"description": "Checks if two strings are anagrams of each other.",
49+
"code": [
50+
"def is_anagram(s1, s2):",
51+
" return sorted(s1) == sorted(s2)",
52+
"",
53+
"# Usage:",
54+
"print(is_anagram('listen', 'silent')) # Output: True"
55+
],
56+
"tags": ["python", "string", "anagram", "check", "utility"],
57+
"author": "SteliosGee"
58+
},
59+
{
60+
"title": "Remove Punctuation",
61+
"description": "Removes punctuation from a string.",
62+
"code": [
63+
"import string",
64+
"",
65+
"def remove_punctuation(s):",
66+
" return s.translate(str.maketrans('', '', string.punctuation))",
67+
"",
68+
"# Usage:",
69+
"print(remove_punctuation('Hello, World!')) # Output: 'Hello World'"
70+
],
71+
"tags": ["python", "string", "punctuation", "remove", "utility"],
72+
"author": "SteliosGee"
3173
}
3274
]
3375
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /