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
d323a9f6
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
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
53e9cfae
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
609712de
def count_chars(text): return {c: text.count(c) for c in set(text)}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
08d11604
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3c50f596
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
d1223660
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
39fd3c06
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
6c5be745
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
c2b6106a
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
10a89950
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
8fd5c4bc
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
fc375bed
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
ae348498
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
b853ed69
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Nhóm items theo key. Tạo dictionary với key là group, value là list.
Regex pattern matching cho text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
be6c0b56
# File I/O def read_file(path): with open(path) as f: return f.read()
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
4ef9dee5
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
eddaac82
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
a471965a
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
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
f244194a
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
6e792b17
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
b651c9aa
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
0d840edf
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
8ad73094
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
7e439f81
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
f383fd9c
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
6cb088e0
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
36d6f734
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
5d0e04a7
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
99e68e27
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
116ed628
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
ac2197ea
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đảo ngược thứ tự các từ trong text.
Regex pattern matching cho text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
151db98d
# File I/O def read_file(path): with open(path) as f: return f.read()
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
4056b33e
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
3dd36a97
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
09701bba
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
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
a9541e85
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
37b89903
def count_chars(text): return {c: text.count(c) for c in set(text)}
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
ddfa0238
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
1d4df7d5
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
1b6a6e52
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
85582d1a
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
7d3314e0
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a7785e8e
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
60792cfb
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ee28305f
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
5cf1d939
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
13af4820
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
9293d56a
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Đếm tần suất xuất hiện của mỗi ký tự.
Regex pattern matching cho text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
5ae3a6ac
# File I/O def read_file(path): with open(path) as f: return f.read()
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
25a430d1
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
a622854b
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
74c88198
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
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
bc1337a0
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
977810cd
def count_chars(text): return {c: text.count(c) for c in set(text)}
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
70449194
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
5c75abba
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
b61c7644
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
fc50e23a
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
707d66e8
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
bbd7dcc4
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
31f27405
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
48e0480e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
c72cf7b6
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
58eb1a53
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
92beb201
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Làm phẳng list nested thành flat list.
Regex pattern matching cho text processing.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
91cb1d34
# File I/O def read_file(path): with open(path) as f: return f.read()
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
493c949f
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
db3ec1da
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
3d225f84
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
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
8c547856
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
8073c19d
def count_chars(text): return {c: text.count(c) for c in set(text)}
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
62abd1d8
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
c3c1cc03
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
81df74c1
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
a3e96d8d
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
f43e8133
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
f8305441
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
40cab2c1
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
96e3bd74
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
f60654fe
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
acd6a565
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
3677ff66
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Gộp nhiều dictionaries thành một.
Regex pattern matching cho text processing.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
1cb1277a
# File I/O def read_file(path): with open(path) as f: return f.read()
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
dcae50a9
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
c5afa231
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
24dae7f1
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
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
05c7e208
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
63e8bc41
def count_chars(text): return {c: text.count(c) for c in set(text)}
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
bc1e3ae6
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
2499c546
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
c58fd120
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
758345c2
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
3d4a5b2e
def is_prime(n): return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
a82b86d8
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
e8b4bbce
# Decorators def log_calls(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
91a0ab11
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
1d53b3a9
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
bed2dbb0
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
179a1c0d
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Chuyển đổi string thành int, trả về default nếu lỗi.
Regex pattern matching cho text processing.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
c7d0ea6b
# File I/O def read_file(path): with open(path) as f: return f.read()
Fibonacci recursive. Chậm nhưng minh họa recursion.
Regex pattern matching cho text processing.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]