I want make a program that calculates the cartesian products of two sets. e.g.:
This is how i would like the result to look like:
Enter two sets to calculate the cartesian product: set([7,9]), set([1,5])
def main(): userinput = input('Enter two sets to calculate the cartesian product: ') set1, set2 = userinput.split(',') myset1 = eval(set1.strip()) myset2 = eval(set2.strip()) ...? main()
I've now made a function who you now can insert two sets in the function and the function will make the two sets from being two 'str' to two 'set'. Now I would like the first element in the first set to pair up with the first element in the second set, then the second element in the first set to pair up with the first element in the second set and so forth.. I think you get the point. The problem is that I dont know how to make python do this.
:X Please help me