![]() |
list - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: list (/thread-9130.html) |
list - zowhair - Mar-22-2018 Hi friends can anyone explain this for me def test1(): l = [] for i in range(1000): l = l + [i]how this statement [python] for i in range(1000): l = l + [i] appends the value of i in the list l ??? RE: list - buran - Mar-22-2018 addition of lists is same as list.extend() >>> l1 = [1,2] >>> l2 = [3, 4] >>> l1+l2 [1, 2, 3, 4] >>> l1.extend(l2) >>> l1 [1, 2, 3, 4] >>> of course in python2 you can do l = range(1000)or in python3 l = list(range(1000)) RE: list - zowhair - Mar-22-2018 got your point. thanks man |