I have a string:
50 5 10 4 48 34
Where each value corresponds to the following notation scheme:
x1 y1 x2 y2 x3 y3
that is, it means that:
x1 = 50
y1 = 5
etc.
At the input, a numeric string separated by spaces is written to my variable, I want to get a list from it, in which tuples storing coordinates are written comma-separated, that is:
[(50, 5), (10, 4), (48, 34)]
please tell me how to do this?
Try this -
input_string = "50 5 10 4 48 34"
numeric_values = input_string.split()
coordinates = [(int(numeric_values[i]), int(numeric_values[i + 1])) for i in range(0, len(numeric_values), 2)]
print(coordinates)