Learn Pythonone of the most popular programming languages
Learn Python
one of the most popular programming languages
Python is a popular, easy-to-learn programming language used for a variety of purposes including web development, data analysis, and artificial intelligence
Recent Articles
FROM BEGINNER TO DEV
Explore Python
Learn the fundamentals with real-life examples
Enhance your Python learning journey with real-world examples. Our examples demonstrate how to apply Python syntax and constructs to solve problems, giving you a head start on your programming projects. Plus, we'll showcase various approaches to tackling challenges, making it easier to become a proficient Python programmer
def method_one(entries: Sequence[int], threshold: int): result = [] for entry in entries: if entry >= threshold: result.append(entry) return result def method_two(entries: Sequence[int], threshold: int): for entry in entries: if entry >= threshold: yield entry def method_three(entries: Sequence[int], threshold: int): return [entry for entry in entries if entry >= threshold] def main(): values = [1,5,293,192,391,102,203,203] print(method_one(values, 100)) print(list(method_two(values, 100))) print(method_three(values, 100))
FREQUENT PROBLEMS
Common Python Questions
What is the difference between append and extend
Learn how to check if a value exists in a list in Python with multiple code examples. Discover four different methods using the in operator, index() method, count() method, and a for loop.
Learn now
How to remove all whitespaces in a string
Learn how to remove all whitespaces from a string in Python using four different methods: replace(), join() and a list comprehension, join() and a generator expression, and translate() and a translation table
Learn now
What does yield do in Python
Learn what the yield keyword does in Python and how to use it to create iterators and generate sequences of values
Learn now
Get the class name of an instance
Learn how to get the class name of an instance in Python using the __class__ attribute or the type() function
Learn now