# Python | Check if all values ​​in the list are greater than the specified value

Python Methods and Functions

For a given list, output all values ​​in the list that are greater than the specified value.

Examples:

` 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 Step 1: traversing the list

By traversing the list, we can compare each element and check if all the elements in the given list are greater than a given value or not.

 ` # Python program to check if all ` ` # there are more values ​​in the list ` ` # than val using traversal `   ` def ` ` check (list1, val): `   ` # move to list ` ` for ` ` x ` ` in ` ` list1: `   ` # compare with all values ​​` ` ` ` # with val ` ` if ` ` val & gt; ` ` = ` ` x: ` ` return ` ` False `  ` return ` ` True `   ` `  ` # driver code ` ` li st1 ` ` = ` ` [` ` 10 ` `, ` ` 20 ` `, ` ` 30 ` `, ` ` 40 ` `, ` ` 50 ` `, ` ` 60 ` `] ` ` val ` ` = ` ` 5 ` ` if ` ` (check (list1, val)): ` ` print ` `" Yes "` ` else ` ` : ` ` print ` ` "No" `   ` val ` ` = ` ` 20 `  ` if ` ` ( check (list1, val)): ` ` print ` `" Yes "` ` else ` `: ` ` print ` ` "No" `

Exit :

` Yes No `

Method 2. Using the all () function:

Using the

` # Python program to check if everything is `
` # there are more values ​​in the list `
` # than val using all () `

` def ` ` check (list1, val): `

` return ` ` (` ` all ` ` (x & gt; val ` ` for ` ` x ` ` in ` ` list1)) `

` `
` # driver code `

` list1 ` ` = ` ` [` ` 10 ` `, ` ` 20 ` `, ` ` 30 ` `, ` ` 40 ` `, ` ` 50 ` `, ` ` 60 ` `] `

` val ` ` = ` ` 5 `

` if ` ` (check (list1, val)): `

` print ` ` "Yes" `

` else ` `: `

` print ` ` "No" `

` val ` ` = ` ` 20 `

` if ` ` (check (list1, val)): `

` ` ` print ` ` "Yes" `

` else ` `: `

` print ` `" No "`

Output:

` Yes No `