0

I have a loop

for i in range(0,1000,100):

and inside it I compute a list which holds 10 values but the loop goes from 0 to 1000.I want to relate these 10 values with the 1000 values; namely, create a list (or array) which will hold these values (the 10 to 1000 values).

UPDATED------------------------------------------

I want to make a plot which will have in the horizontal axis values from 0 to 1000 and in the vertical axis the 10 values of the list that i computed.

George
  • 5,808
  • 15
  • 83
  • 160
  • 2
    I ... can't quite tell what you're asking here. In what way do you want to "relate" them? Can you provide your desired output structure (dict, nested list, etc)? Doing so may make it easier to answer. – g.d.d.c Nov 18 '11 at 16:40
  • Hello,it has to do with this "http://stackoverflow.com/questions/8124032/python-scipy-homework-how-to-keep-history-of-the-particle-position-in-the-gr" .I think ,i need to append to "means" which has 10 values ,the number of the steps ,which are 1000 – George Nov 18 '11 at 16:42
  • 1
    @George If your question is unclear (and it is to me) edit the question itself, so that it is self contained. – Eric Wilson Nov 18 '11 at 16:56

2 Answers2

0

Your question is very unclear.

From your comment it seems like you're asking about matplotlib? Do you want something like this?

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0, 1000, 100)
# As a placeholder for your calculation...
y = np.cos(x / 100.0)  

plt.plot(x, y, marker='o', mfc='red')
plt.show()

enter image description here

Joe Kington
  • 275,208
  • 71
  • 604
  • 463
  • Hello and thanks.I will accept this answer because i couldn't explain clearly what i wanted but it was sth like that. – George Nov 18 '11 at 20:47
0

Do you want to access the list elements while retaining the range from 0 to 1000 in steps of 100? If so, this should be a way.

mylst=[12,5,6,34,6,11,78,1,1,88]

for i in range(0,1000,100):
    print mylst[i/100]

Not sure... a more detailed question could help.

bdhar
  • 21,619
  • 17
  • 70
  • 86