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
7d1aff10
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5750c0df
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
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
44aa7de4
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
db74577c
def count_chars(text): return {c: text.count(c) for c in set(text)}
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
ce97845d
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
a838f202
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.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
537b3d65
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
051f8919
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
a79793a8
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.
JSON là standard format cho data interchange.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
94df21f1
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
b79c16d0
# 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.
JSON là standard format cho data interchange.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
fe38b73e
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
5e8b8e95
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
c5440fde
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
7ad68e6b
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Extract emails từ text dùng regex pattern.
JSON là standard format cho data interchange.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
85fd4271
# File I/O def read_file(path): with open(path) as f: return f.read()
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
cace1235
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
9c54442c
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
27461f58
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.
JSON là standard format cho data interchange.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
05972ffc
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
4e5c7f2c
def count_chars(text): return {c: text.count(c) for c in set(text)}
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
448c7c7f
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
9113e5e5
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.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
9dd2eb92
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
d354e948
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
a81755f5
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.
JSON là standard format cho data interchange.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
af481e09
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
1c7f363a
# 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.
JSON là standard format cho data interchange.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
ac867e3c
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
80201712
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
6b041578
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
545eea4e
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Load JSON từ file. Trả về parsed object.
JSON là standard format cho data interchange.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
9b26f181
# File I/O def read_file(path): with open(path) as f: return f.read()
Save data thành JSON file.
JSON là standard format cho data interchange.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
cc750699
def write_file(path, content): with open(path, 'w') as f: f.write(content)
Save data thành JSON file.
JSON là standard format cho data interchange.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
1debd094
# Data Processing def process_data(items): return [x.strip().lower() for x in items if x]
Save data thành JSON file.
JSON là standard format cho data interchange.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
40201f93
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.
JSON là standard format cho data interchange.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
991a90d3
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Save data thành JSON file.
JSON là standard format cho data interchange.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
388d2848
def count_chars(text): return {c: text.count(c) for c in set(text)}
Save data thành JSON file.
JSON là standard format cho data interchange.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
02a2c6fc
# Lists & Dicts def flatten(nested): return [item for sublist in nested for item in sublist]
Save data thành JSON file.
JSON là standard format cho data interchange.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
ee3f04a2
def merge_dicts(*dicts): return {k:v for d in dicts for k,v in d.items()}
Save data thành JSON file.
JSON là standard format cho data interchange.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
f17a1f35
# Error Handling def safe_int(value, default=0): try: return int(value) except: return default
Save data thành JSON file.
JSON là standard format cho data interchange.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
dab57fd3
# Algorithms def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2)
Save data thành JSON file.
JSON là standard format cho data interchange.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
2c7de1f1
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.
JSON là standard format cho data interchange.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
c8954a19
# OOP class BaseModel: def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return self.__dict__
Save data thành JSON file.
JSON là standard format cho data interchange.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
db0d7a7f
# 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.
JSON là standard format cho data interchange.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
f5268086
# Working with APIs def fetch_data(url): import requests return requests.get(url).json()
Save data thành JSON file.
JSON là standard format cho data interchange.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
bd1c881f
# Regular Expressions def extract_emails(text): import re return re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', text)
Save data thành JSON file.
JSON là standard format cho data interchange.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
6724d833
# JSON Operations def load_json(path): with open(path) as f: return json.load(f)
Save data thành JSON file.
JSON là standard format cho data interchange.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
e62a221a
def save_json(path, data): with open(path, 'w') as f: json.dump(data, f)
Save data thành JSON file.
JSON là standard format cho data interchange.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
4455f512
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
34ccf708
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.
File operations là fundamentals trong programming.
python
intermediate
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
10a74255
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
54865d34
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.
File operations là fundamentals trong programming.
python
beginner
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
5afbf475
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
5b4daa5d
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.
File operations là fundamentals trong programming.
python
advanced
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
2e74bda4
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
3401e947
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.
File operations là fundamentals trong programming.
python
intermediate
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
38bf0a83
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
cb12b2e9
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
fc3f27a5
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.
File operations là fundamentals trong programming.
python
intermediate
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
45066d59
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
88fcdcdc
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
be0d19fe
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
57d8d20c
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
f0c3002b
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
3a76365b
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.
File operations là fundamentals trong programming.
python
intermediate
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
3ad85ee1
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
08c91fb7
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.
File operations là fundamentals trong programming.
python
beginner
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
ce994170
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
99a59e2c
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.
File operations là fundamentals trong programming.
python
advanced
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
4a93c08e
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Ghi nội dung vào file. Context manager tự động đóng file.
File operations là fundamentals trong programming.
python
beginner
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
8acc20aa
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.
File operations là fundamentals trong programming.
python
intermediate
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
c59c51a0
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
8f8adb15
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.
File operations là fundamentals trong programming.
python
beginner
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
ca991ee6
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
a98439d8
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
33314cf3
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.
File operations là fundamentals trong programming.
python
beginner
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
411e8908
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
a4ea6acf
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
50bc784d
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
db9646e2
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
656ce363
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
dd7b2548
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.
File operations là fundamentals trong programming.
python
beginner
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]
aa89290d
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "file-io", "context-manager" ]
3.9+
[ "python", "function", "example" ]
f011e9e1
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.
File operations là fundamentals trong programming.
python
advanced
[ "list-processing", "data-structures" ]
3.9+
[ "python", "function", "example" ]
09196daa
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "string", "text-processing" ]
3.9+
[ "python", "function", "example" ]
5ee3ad2b
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.
File operations là fundamentals trong programming.
python
intermediate
[ "grouping", "dict" ]
3.9+
[ "python", "function", "example" ]
7443706d
# String Operations def reverse_words(text): return ' '.join(text.split()[::-1])
Xử lý danh sách: strip spaces, convert to lowercase, filter empty.
File operations là fundamentals trong programming.
python
advanced
[ "string", "manipulation" ]
3.9+
[ "python", "function", "example" ]
7663f40e
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.
File operations là fundamentals trong programming.
python
beginner
[ "dict", "counting" ]
3.9+
[ "python", "function", "example" ]
5c6ebb96
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "list", "flattening" ]
3.9+
[ "python", "function", "example" ]
172dc1b8
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.
File operations là fundamentals trong programming.
python
advanced
[ "dict", "merging" ]
3.9+
[ "python", "function", "example" ]
a9dd629c
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "error-handling", "type-conversion" ]
3.9+
[ "python", "function", "example" ]
e376b8ec
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "recursion", "algorithm" ]
3.9+
[ "python", "function", "example" ]
e33612da
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.
File operations là fundamentals trong programming.
python
advanced
[ "algorithm", "math" ]
3.9+
[ "python", "function", "example" ]
bc884491
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "class", "oop" ]
3.9+
[ "python", "function", "example" ]
11a05aec
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "decorator", "function" ]
3.9+
[ "python", "function", "example" ]
457da1f6
# 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.
File operations là fundamentals trong programming.
python
advanced
[ "api", "http" ]
3.9+
[ "python", "function", "example" ]
54432d3e
# 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.
File operations là fundamentals trong programming.
python
beginner
[ "regex", "pattern-matching" ]
3.9+
[ "python", "function", "example" ]
3493bbe8
# 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.
File operations là fundamentals trong programming.
python
intermediate
[ "json", "file-io" ]
3.9+
[ "python", "function", "example" ]
91c4df53
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.
File operations là fundamentals trong programming.
python
advanced
[ "io", "file-operations" ]
3.9+
[ "python", "function", "example" ]