Append a Python List to Itself

Опубликовано: 05 Январь 2023
на канале: Data Believer
137
4

GitHub: https://github.com/databeliever/Tips-...

Suppose you have a database that is a list in Python. For your purposes, it's too small. You also have nowhere to get more data from. You want to increase its size by duplicating its values. When you want to double a list in Python by duplicating its contents, there are two ways. 
The first is a flat list, where the original values [1, 2, 3] are simply appended to the end of the list, resulting in a list of [1, 2, 3, 1, 2, 3]. The second is a nested list, where the original list is added as an element within a new list, resulting in a list of [1, 2, 3, [1, 2, 3]].
The first solution that may come to mind for a beginner is to use the 'append' method. This seems like logical reasoning; after all, it is used to add values to a list. But is this the right approach?

Python visualization: https://pythontutor.com/
#python #pythontutorial #pythonprogramming

#python #programming #tutorial #learnprogramming


На этой странице сайта вы можете посмотреть видео онлайн Append a Python List to Itself длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Data Believer 05 Январь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 137 раз и оно понравилось 4 зрителям. Приятного просмотра!