Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_if_any_3_in_sublists.py
- main_list = [[3, 4, 5, 6], [3, 1, 4, 2], [1, 0, 4, 2], [3, 2, 9, 0], [3, 1, 1, 1]] # Example main list
- nums = [9, 1, 2, 3] # Numbers to check
- for sublist in main_list:
- matching_count = 0
- for num in nums:
- if num in sublist:
- matching_count += 1
- if matching_count >= 3:
- print("3 numbers from [9, 1, 2, 3] matches those in the sublist", sublist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement