+ 3

Create an array of size 20 with random 2-digit values. Replace all numbers divisible by 3 to 'abc'.

Create an array of size 20 with random 2-digit values. Replace all numbers divisible by 3 to 'abc'. A3 = np.arange(10, 30) print("\nOne-dimensional array of three digit numbers:") idx = (A3%3==0) idx=np.where(idx) A3[idx]='abc' print(len(A3)) can you tell how I fix

3rd Oct 2021, 11:25 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
2 odpowiedzi
+ 1
from random import randrange as rr l = [int(str(rr(10))+str(rr(10))) for i in range(20)] l2 = ['abc' if i%3==0 else i for i in l ]
4th Oct 2021, 8:02 AM
Shadoff
Shadoff - avatar