I am trying to create a list of size 9 (but that can change) which is populated with numbers from the range of [-pi/2,pi/2] where basically the range is split into 9 numbers and those 9 numbers are what the list is populated with.
            Asked
            
        
        
            Active
            
        
            Viewed 882 times
        
    -2
            
            
        - 
                    5IIUC, you're looking for [`numpy.linspace`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html). Looking for a dupe. – pault Feb 27 '19 at 20:26
- 
                    TL; DR: `np.linspace(-pi/2,pi/2,n)` – pault Feb 27 '19 at 20:36
- 
                    Do you want the `pi/2` end point? There's a difference between how `np.arange` and `np.linspace` handle end points. – hpaulj Feb 28 '19 at 05:02
- 
                    Yes, I do want pi/2 as the endpoint. Linspace did exactly what I needed. – tethys4 Feb 28 '19 at 19:28
2 Answers
0
            
            
        import math
import numpy as np
liste=np.arange(-math.pi/2, math.pi/2+0.01, math.pi/8)
 
    
    
        Cody Gray - on strike
        
- 239,200
- 50
- 490
- 574
 
    
    
        Menroka
        
- 19
- 5
- 
                    1Code-only answers are discouraged. Please click on [edit] and add some words summarising how your code addresses the question, or perhaps explain how your answer differs from the previous answer/answers. [From Review](https://stackoverflow.com/review/low-quality-posts/22328139) – Nick Feb 28 '19 at 00:37
- 
                    1The superficiality of the review comments bugs me. That said, you should display `liste`. Other answers and comments use `linspace`. It handles the end point better. – hpaulj Feb 28 '19 at 05:00
 
    