Here are the two lists I have :
l1 = ['5', '10', '15', '20', '25', '30', '35', '40', '45']
l2 = ['0.011530', '0.039914', '0.085069', '0.145798', '0.213572', '0.287898', '0.355587', '0.413209', '0.472346']
thanks to these two lists I would like to create two lists with the same values but with some changes :
new_list1 = [5,10,10,15,15,20,20,25,25,30,30,35,35,40,40,45,45]
new_list2 = ['0.011530', '0.011530', '0.039914', '0.039914', '0.085069', '0.085069', '0.145798', '0.145798', '0.213572', '0.213572', '0.287898', '0.287898', '0.355587', '0.355587', '0.413209', '0.413209', '0.472346']
the purpose of this two new lists is to create a graph and instead of a line, I will get steps.
[What I dont want]

[What I want]

so as a beginner i wrote that :
def test():
new_list1.insert(0,l1[0])
new_list2.insert(0,l2[0])
new_list1.insert(1,l1[1])
new_list2.insert(1,l2[0])
new_list1.insert(2,l1[1])
new_list2.insert(2,l2[1])
new_list1.insert(3,l1[2])
new_list2.insert(3,l2[1])
new_list1.insert(4,l1[2])
new_list2.insert(4,l2[2])
new_list1.insert(5,l1[3])
new_list2.insert(5,l2[2])
new_list1.insert(6,l1[3])
new_list2.insert(6,l2[3])
new_list1.insert(7,l1[4])
new_list2.insert(7,l2[3])
new_list1.insert(8,l1[4])
new_list2.insert(8,l2[4])
new_list1.insert(9,l1[5])
new_list2.insert(9,l2[4])
new_list1.insert(10,l1[5])
new_list2.insert(10,l2[5])
new_list1.insert(11,l1[6])
new_list2.insert(11,l2[5])
new_list1.insert(12,l1[6])
new_list2.insert(12,l2[6])
new_list1.insert(13,l1[7])
new_list2.insert(13,l2[6])
new_list1.insert(14,l1[7])
new_list2.insert(14,l2[7])
new_list1.insert(15,l1[8])
new_list2.insert(15,l2[7])
new_list1.insert(16,l1[8])
new_list2.insert(16,l2[8])
print(new_list1)
print(new_list2)
x = np.array(new_list1)
y = np.array(new_list2)
# plotting
plt.title("Line graph")
plt.xlabel("X axis")
plt.ylabel("Y axis")
plt.plot(x, y, color ="green")
plt.show()
which makes the trick, but I want it to be more "beautiful" and easy to read, with some "for" loop. How can I do that ?



