- 3

nums = [-1, 2, -3, 4, -5] if all([abs(i) < 3 for i in nums]): print(1) else: print(2

6th Jun 2021, 5:26 AM
Tia
4 Answers
0
2
6th Jun 2021, 5:26 AM
Tia
0
what is your question/problem? all() function return True if all items of iterable passed as argument are evaluated to True: in the ptovided case, abdolute value of three last elements are not lesser than 3, so else statement is executed ^^
6th Jun 2021, 5:43 AM
visph
visph - avatar
0
2
10th Sep 2022, 9:53 AM
Ermiyas Yeshambel Belay
Ermiyas Yeshambel Belay - avatar
0
Not all the abs(i) are <3 , so it will print 2.
27th Sep 2022, 12:48 PM
HEMRAJ LAKRA
HEMRAJ LAKRA - avatar