Telegram Group & Telegram Channel
Difference between list and tuple in python

🔸List is mutable ( you can modify the original list) and it's values are written in sqare brackets [ ]

🔸Tuple is immutable ( you can't modify it) and it's values are written in parentheses ( ) delimited by comma( , )

🔸To convert list to tuple - we use tuple() function
list1 = [1,2,3]
print(tuple(list1)) Output : (1,2,3)

🔸 For single element list
list1 = [1]
print(tuple(list1)) Output : (1, )

▪️a tuple is a tuple because of comma not because of parentheses


@Python_Codes



tg-me.com/python_codes/224
Create:
Last Update:

Difference between list and tuple in python

🔸List is mutable ( you can modify the original list) and it's values are written in sqare brackets [ ]

🔸Tuple is immutable ( you can't modify it) and it's values are written in parentheses ( ) delimited by comma( , )

🔸To convert list to tuple - we use tuple() function
list1 = [1,2,3]
print(tuple(list1)) Output : (1,2,3)

🔸 For single element list
list1 = [1]
print(tuple(list1)) Output : (1, )

▪️a tuple is a tuple because of comma not because of parentheses


@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/224

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

Launched in 2013, Telegram allows users to broadcast messages to a following via “channels”, or create public and private groups that are simple for others to access. Users can also send and receive large data files, including text and zip files, directly via the app.The platform said it has more than 500m active users, and topped 1bn downloads in August, according to data from SensorTower.Python Codes from us


Telegram Python Codes
FROM USA