Creating line segment lists from x,y lists in Python -


I want to sync data for the rectangle in two lists (for example):

 < Code> X = [1, 8, 9, 4] y = [2, 3, 6, 7]  

I want to make a list of line segment endpoint representing the rectangles. . The list will ideally be:

  segment_endpoints = [((1, 2), (8, 3)), ((8, 3), (9, 6)), (( 9, 6), (4, 7)), ((4, 7), (1, 2))  

My attempt:

  Vertices = zip (x, y) segment_endpoints = zip (vertices, vertices [1:] + [parenthesis [0]])  

But Python will not let me zip a zipped object.

Surely there is an easy way to do this. New for Programming New StackHowflow in New

When you use the list in Python 3 ( [10]: In the [10]: Courses = list (zip (x, y)) [11]: list (zip (meridian, meridian [1:] +) [Meridians [0]])) [11]: [((1, 2), (8, 3)), ((8, 3), (9, 6)), (9, 6), (4, 7)), (1, 2))

in python3 zip as an iterator returns python2 You list in the list (zip ()) synta Must use S.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -