Please how can I check an array in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Please how can I check an array in python

That's, I want to verify if a certain value in my array of integers is greater than 16!

22nd Nov 2020, 4:29 PM
Rawley
Rawley - avatar
6 Answers
+ 6
Jan Markus' second answer should be what you need. It can be shortened: test = any(i > 16 for i in arr) You could also use max: test = max(arr) > 16 Any is the better solution though
22nd Nov 2020, 5:11 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
Thanks very much guys(am new to python) I just did it but had to test for i<16 and print "no way" if true else "let's go" if false. the other way round will not always work. Thnks tho
23rd Nov 2020, 4:09 AM
Rawley
Rawley - avatar
+ 1
My real problem is like: The user inputs 3 integers as an array and you have to check If any value is greater than 16.
22nd Nov 2020, 4:44 PM
Rawley
Rawley - avatar
+ 1
😑😑😑 sorry but it doesn't solve the problem!
22nd Nov 2020, 5:01 PM
Rawley
Rawley - avatar
+ 1
It should print say "let's go" if at least 16 and "no way" if less than 16. So the user inputs 3 values in an array and the code checks..... that's what am trying to do🙏
22nd Nov 2020, 5:14 PM
Rawley
Rawley - avatar
+ 1
Ok thnks
23rd Nov 2020, 4:00 AM
Rawley
Rawley - avatar