Python | Check if all the values in a list that are greater than a given value
Given a list, print all the values in a list that are greater than the given value
Input : list = [10, 20, 30, 40, 50] given value = 20 Output : No Input : list = [10, 20, 30, 40, 50] given value = 5 Output : Yes
Method 1: Traversal of list
By traversing in the list, we can compare every element and check if all the elements in the given list are greater than the given value or not.
Method 2: Using all() function:
Using all() function we can check if all values are greater than any given value in a single line. It returns true if the given condition inside the all() function is true for all values, else it returns false.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course