|
42 | 42 | ],
|
43 | 43 | "tags": ["python", "string", "palindrome", "utility"],
|
44 | 44 | "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" |
45 | 87 | }
|
46 | 88 | ]
|
47 | 89 | },
|
|
0 commit comments