'Python program that checks if at least half of the elements in a list are tuples
I am fairly new to python and Im really having a hard time following the logic in checking only at least half of the elements in a list.
Solution 1:[1]
my_list = [(2,3), (6,4) ,1]
tuple_count = 0
for x in my_list:
if isinstance(x,tuple):
tuple_count = tuple_count + 1
print(tuple_count > len(my_list)//2)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Akash garg |
