Created
April 19, 2022 15:21
-
-
Save a1exDi/8fb837c7f6b5705cc7ccc557f9580d70 to your computer and use it in GitHub Desktop.
Добавить значение в list с помощью метода insert в независимости от длинны списка
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = [1,2,3,4,5] # Список в который нужно добавить 6, 7 ... в конец списка с помощью insert | |
len_numbers = len(numbers) # Считаем колличество элементов в списке и присваиваем переменной | |
numbers.insert(len_numbers, 6) | |
len_numbers = len(numbers) | |
numbers.insert(len_numbers, 7) | |
print(numbers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment