[Solved] Can someone tell me what this statement does? [closed]


a.strip().split() produces a list of strings of the form 'a-b' where the a and b are composed of digit characters.

This means that:

alignment = set([tuple(map(int, x.split("-"))) for x in a.strip().split())

produces a set from a list defined by a list comprehension. The list comprehension takes each of these 'a-b' strings, spits it into two on the '-' character and then converts each of those from string to integer value by mapping the int function onto them, and then lastly converts the resulting pair into a tuple of two integer values — this results is a set being produced from a list of tuples — which is the result you’re seeing.

solved Can someone tell me what this statement does? [closed]