Feb-16-2020, 07:04 PM
(This post was last modified: Feb-16-2020, 07:05 PM by michaelko03.)
Here is my code
can anyone help me? Thank you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import math import numpy as np z = 0 y = [] x = [] while z < 5 : z = z + 1 t = 0 x.append([y]) while t < 8 : A = 10 + t y.append(A) t = t + z print (x) I want to separate the result of y list in each cycle from the second while loop I expect the result will be [ 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 ], [ 10 , 12 , 14 , 16 ],[ 10 , 13 , 16 ], [ 10 , 14 ], [ 10 , 15 ] [ 10 , 16 ] but the outcome is [ 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 10 , 12 , 14 , 16 , 10 , 13 , 16 , 10 , 14 , 10 , 15 , 10 , 16 [ 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 10 , 12 , 14 , 16 , 10 , 13 , 16 , 10 , 14 , 10 , 15 , 10 , 16 ], [ 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 10 , 12 , 14 , 16 , 10 , 13 , 16 , 10 , 14 , 10 , 15 , 10 , 16 ], [ 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 10 , 12 , 14 , 16 , 10 , 13 , 16 , 10 , 14 , 10 , 15 , 10 , 16 ], [ 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 10 , 12 , 14 , 16 , 10 , 13 , 16 , 10 , 14 , 10 , 15 , 10 , 16 ] |