import random
#import matplotlib.pyplot as plt
a1 = ['','','?','']
a2 = [10,25,43.34,90]
i = 0
i_array = []
while i < 10:
i_array.append(i)
i = i + 1
r = random.random()
for i, j in enumerate(a1):
if j == '?':
print(a2[i]*r)
a3 = a2[i]*r
plt.line(r,a3)
The question mark I have in a1 could be in any place out of those four places. So, the value corresponding to it in a2 needs to be changed. the answer: import random #import matplotlib.pyplot as plt
a1 = ['','','?','']
a2 = [10,25,43.34,90]
xarray=[]
yarray=[]
i = 0
i_array = []#probably can delete this, I don't see any reason for it
for i in range(0,10):#use a for loop instead
i_array.append(i)
r = random.random()
a3 = a2[a1.index('?')]*r#index here instead of the for loop
print(a3)#since your assigning a3 anyway, might as well print that
xarray.append(r)#plot needs arrays
yarray.append(a3)
plt.plot(xarray,yarray)#plot your arrays