- 2

A program to find any 11 num in a given array

Python

10th Jun 2021, 10:42 AM
Sonam Bharti
Sonam Bharti - avatar
3 Antworten
+ 3
To check if the element exists, use any of the 3 methods: > in operator (returns true if it exist) >count function (if count is !=0, element exist) ><list>.index(element) (returns -1: element doesn't exist)
10th Jun 2021, 12:49 PM
Isaac Fernandes
Isaac Fernandes - avatar
+ 1
Find count of 11s or the indices of them ?
10th Jun 2021, 12:11 PM
Alex
0
you could use filter() function to get a new list with all 11's in a list/array or do it with list comprehension ;) elevens = [v for v in thelist if v==11] elevens = filter(lambda v: v==11, thelist) https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/methods/built-in/filter
10th Jun 2021, 1:30 PM
visph
visph - avatar