added exercises for list comprehensions
This commit is contained in:
36
list_comprehensions/comprehensions.py
Normal file
36
list_comprehensions/comprehensions.py
Normal file
@ -0,0 +1,36 @@
|
||||
def divisible_by_7(n: int) -> list[int]:
|
||||
"""
|
||||
Returns a list of all numbers till 'n' that are divisible by '7'
|
||||
"""
|
||||
|
||||
|
||||
def contains_3(n: int) -> list[int]:
|
||||
"""
|
||||
Returns a list of all numbers that contain the digit '3' in them
|
||||
"""
|
||||
|
||||
|
||||
def count_spaces(string: str) -> int:
|
||||
"""
|
||||
Count the spaces in a string
|
||||
"""
|
||||
|
||||
|
||||
def remove_vowels(string: str) -> str:
|
||||
"""
|
||||
Remove all vowels from the string
|
||||
"""
|
||||
|
||||
|
||||
def word_lengths(string: str) -> dict[str, int]:
|
||||
"""
|
||||
Create a dictionary of all words with their lengths
|
||||
"""
|
||||
|
||||
|
||||
def prime_numbers(n: int) -> list[int]:
|
||||
"""
|
||||
Returns a list of all prime numbers till 'n' (HARD)
|
||||
"""
|
||||
|
||||
|
Reference in New Issue
Block a user