Jan-30-2021, 04:51 AM
(Jan-30-2021, 03:52 AM)bowlofred Wrote:(Jan-30-2021, 02:29 AM)karabakh Wrote: When I add the ids to some list, the list is not being overwritten.
That's because you're using a method of the list that modifies it, likelist.append()
. What you're not doing is reassigning the list each time through likelist = [new_item]
.
With strings, you'd instead assign the existing part and the new part to a variable. Something like:
full_string = "" for s in list: full_string += s # Keeps the existing portion each time through the loop.
Thank you. I also discovered extend which seems to be what you are mentioning here.