Skip to content

Instantly share code, notes, and snippets.

@a1exDi
Created April 19, 2022 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1exDi/8fb837c7f6b5705cc7ccc557f9580d70 to your computer and use it in GitHub Desktop.
Save a1exDi/8fb837c7f6b5705cc7ccc557f9580d70 to your computer and use it in GitHub Desktop.
Добавить значение в list с помощью метода insert в независимости от длинны списка
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