দুটি বা অধিক লিস্টের প্রতিটি এলিমেন্ট মিলিয়ে সকল সম্ভাব্য পারমুটেশন (কার্তেসিয়ান প্রোডাক্ট) বের করার দুটি পদ্ধতি।
১. লিস্ট কম্প্রিহেনশন (নেস্টেড ফর লুপ)
A = [5,8]
B = [10,15,20]
print("The given lists:", A, B)
permutations = [[m, n] for m in A for n in B]
print("permutations of the given values are:", permutations)
আউটপুট: [[5, 10], [5, 15], [5, 20], [8, 10], [8, 15], [8, 20]]
২. itertools.product() ব্যবহার
import itertools
A = [5,8]
B = [10,15,20]
print("The given lists:", A, B)
result = list(itertools.product(A, B))
print("permutations of the given lists are:", str(result))