10th May 2020, 3:22 AM
51207
51207 - avatar
8 Réponses
+ 3
What are you trying to achieve? Deep copying a to b? import copy a=[1,2,3,4] b=copy.deepcopy(a) print(b)
10th May 2020, 3:37 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Cant be like this a=[1,2,3,4] x=0 while True: b=a[x] if len(a)<5: print(b) x+=1
10th May 2020, 3:31 AM
51207
51207 - avatar
0
Instead of writing, b = a[5] Write, b = a[1] Output will be 2.
10th May 2020, 3:25 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
I think you want to print the elements in the array. Do it like so : a=[1,2,3,4] for i in range(len(a)): print(a[i])
10th May 2020, 3:32 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
i want to make it like 1 2 3 4 1 2 3 4 1 2 a[10]
10th May 2020, 3:37 AM
51207
51207 - avatar
10th May 2020, 3:40 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
Yes, but return a[10] is 3 cause it looping 2x 1=0 2=1 3=2 4=3 1=4 2=5 3=6 4=7 1=8 2=9 3=10 a[10] = 3 maybe?
10th May 2020, 3:44 AM
51207
51207 - avatar
0
a = [1,2,3,4] b = a[1] if len(a) < 5: print(b)
10th May 2020, 11:27 AM
Prashant Pokhriyal
Prashant Pokhriyal - avatar