Skip to content

Commit 1124c4d

Browse files
Merge pull request #29 from SteliosGee/main
Add string utility functions: count vowels, check anagram, and remove punctuation
2 parents e873b56 + 32c722c commit 1124c4d

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
@@ -42,6 +42,48 @@
4242
],
4343
"tags": ["python", "string", "palindrome", "utility"],
4444
"author": "dostonnabotov"
45+
},
46+
{
47+
"title": "Count Vowels",
48+
"description": "Counts the number of vowels in a string.",
49+
"code": [
50+
"def count_vowels(s):",
51+
" vowels = 'aeiou'",
52+
" return len([char for char in s.lower() if char in vowels])",
53+
"",
54+
"# Usage:",
55+
"print(count_vowels('hello')) # Output: 2"
56+
],
57+
"tags": ["python", "string", "vowels", "count", "utility"],
58+
"author": "SteliosGee"
59+
},
60+
{
61+
"title": "Check Anagram",
62+
"description": "Checks if two strings are anagrams of each other.",
63+
"code": [
64+
"def is_anagram(s1, s2):",
65+
" return sorted(s1) == sorted(s2)",
66+
"",
67+
"# Usage:",
68+
"print(is_anagram('listen', 'silent')) # Output: True"
69+
],
70+
"tags": ["python", "string", "anagram", "check", "utility"],
71+
"author": "SteliosGee"
72+
},
73+
{
74+
"title": "Remove Punctuation",
75+
"description": "Removes punctuation from a string.",
76+
"code": [
77+
"import string",
78+
"",
79+
"def remove_punctuation(s):",
80+
" return s.translate(str.maketrans('', '', string.punctuation))",
81+
"",
82+
"# Usage:",
83+
"print(remove_punctuation('Hello, World!')) # Output: 'Hello World'"
84+
],
85+
"tags": ["python", "string", "punctuation", "remove", "utility"],
86+
"author": "SteliosGee"
4587
}
4688
]
4789
},

0 commit comments

Comments
 (0)