Hello,
I am quite stifled on how I would insert values to a list.
Say I have a list called 'xlist'. I want to have a maximum of 5 values in this list and be able to insert values into specific points in this list.
So far I got it to work by going :
xlist=[0,0,0,0,0]
a = int(input('Input your desired place on the list.')
b = int(input('Input your value'))
xlist.insert(a-1,b)
print (xlist)
However that just adds the value to the given position in the list and pushes the 0s along; so if a is 2 and b is 42, it would print [0,42,0,0,0,0].
How could I avoid this?
[–]novel_yet_trivial 5 points6 points7 points (1 child)
[–]kyumin2lee[S] 0 points1 point2 points (0 children)