python - Merging(2 lists) X Coordinate List and Y Coordinate List to Get(1 list) XY Coordinate List -


i have list of:

xvalues = [1,2,3,4,5,6,7,8,9,10] 

and list of:

yvalues = [n1,n2,n3,n4,n5,n6,n7,n8,n9,n10] 

the y-values random thats why being notated are.

i want merge these 2 lists 1 list this:

xyvalues = [(1,n1),(2,n2),(3,n3),(4,n4),(5,n5),(6,n6),(7,n7),(8,n8),(9,n9),(10,n10)] 

and plot them on top of:

x = numpy.linspace(0,15,100) y = 1 plt.plot(x,y,'g') 

can done?

you need zip:

xvalues = [1,2,3,4,5,6,7,8,9,10]   yvalues = ["n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"]  print(zip(xvalues,yvalues)) 

output:

[(1, 'n1'), (2, 'n2'), (3, 'n3'), (4, 'n4'), (5, 'n5'), (6, 'n6'), (7, 'n7'), (8, 'n8'), (9, 'n9'), (10, 'n10')] 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -