id
stringlengths
8
8
code
stringclasses
17 values
explanation
stringclasses
17 values
context
stringclasses
17 values
language
stringclasses
1 value
difficulty
stringclasses
3 values
tags
listlengths
2
2
version
stringclasses
1 value
keywords
listlengths
3
3
192cb73b
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6716532c
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
79e1ccf4
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
0353bf87
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
098bfa30
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
5ffcf468
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
a0059081
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
d262a521
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
c0b5530f
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
3b73becd
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
fd6f8ed0
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
e4adefb5
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
411ca54d
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
fea1d5a9
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
9e942662
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
47677f0c
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
26453a82
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
2b6f2511
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
5fa61c31
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
afb269e5
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
cc1e4aae
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
dca1fbe9
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
299c34c1
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
faaf8b3b
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
fb7cc94b
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
4143c912
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
2c25f377
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
4cac219a
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
8ceb7087
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
0390555b
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
7a0e4988
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
e84688d6
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
aa5f8223
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4f7550b1
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
204daf29
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
16a1d3f9
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
8a39b5d8
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
145a1cc9
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
0bcdf8c0
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
451a8ea0
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
11f00511
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
13bae210
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
bb708a1e
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
358df653
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
7b03f810
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
748f306c
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
85f1f970
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
Counter pattern rất hữu ích trong text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
a1e36f41
# File I/O def read_file(path): with open(path) as f: return f.read()
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
5a525530
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
461896af
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
2a799caf
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
dd280ad8
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
0eb5d22e
def count_chars(text): return {c: text.count(c) for c in set(text)}
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
adc8e2cc
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
714c7a72
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
6494ee31
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e46dc4e9
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6677fbce
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
d67e6f34
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
5ddaa4d7
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ab5988df
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
70eb9e33
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
0be7d95e
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
6aedb2bb
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Hàm này đọc nội dung của file và trả về dưới dạng string.
Flatten thường dùng trước khi process lists.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
57a9683d
# File I/O def read_file(path): with open(path) as f: return f.read()
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
2f56bf77
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
79b70b37
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
4b5e8f9e
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7939d696
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
cf798307
def count_chars(text): return {c: text.count(c) for c in set(text)}
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
d5c1f706
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
41dea86c
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
f69ca0df
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
8dc05bb1
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
42fdc807
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6309d911
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
a47c5b49
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
d50a33a4
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
ab4e3c55
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f030270b
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
74f2ca93
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Ghi nội dung vào file. Context manager tự động đóng file.
Flatten thường dùng trước khi process lists.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5498ce4b
# File I/O def read_file(path): with open(path) as f: return f.read()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
3bd1c7fc
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
d3910400
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
3fdded6e
def group_by_key(items, key): result = {} for item in items: k = item.get(key) if k not in result: result[k] = [] result[k].append(item) return result
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
cac04a55
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
ffa96499
def count_chars(text): return {c: text.count(c) for c in set(text)}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c15a481e
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
f864de3f
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
522ca2bd
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
733873b1
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
97c3cef2
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
97f89ae6
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
0771c3e1
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
98907c53
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
9b863881
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
1019506a
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
94790364
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
Flatten thường dùng trước khi process lists.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
3aef31aa
# File I/O def read_file(path): with open(path) as f: return f.read()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Flatten thường dùng trước khi process lists.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
13515983
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Flatten thường dùng trước khi process lists.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]