Adding elements to a list:-append and extend

 Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license()" for more information.

>>> ##Adding elements to a list

>>> squares=[1,4,9,16]

>>> squares.append(35)

>>> squares

[1, 4, 9, 16, 35]

>>> squares.extend([36,49,64])

>>> squares

[1, 4, 9, 16, 35, 36, 49, 64]

>>> squares.append([36,49,64])

>>> squares

[1, 4, 9, 16, 35, 36, 49, 64, [36, 49, 64]]

>>> 

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions