List

1004
List in python

List, items का एक ordered sequence होता है Python के list data type में एक से ज्यादा items होते है | हर एक item को comma(,) से seperate किया जाता है | list के सभी items को square bracket[] के अन्दर close किये जाता है |

List ये एक compound data type है जिसमे किसी भी data types के items लिए जा सकते है | list ये एक mutable data type है | mutable data type का मतलब यह है कि user इन data type के items की values को update भी कर सकता है।

Python list# Creating a List
List = []
print(“blank List: “)
print(List)

# Creating a List with the use of a String
List = [‘PythonList’]
print(“\n List with the use of String: “)
print(List)

# Creating a List with the use of multiple values
List = [“Python”, “For”, “Programming”]
print(“\n List containing multiple values: “)
print(List[0])
print(List[2])

# Creating a Multi-Dimensional List (By Nesting a list inside a List)
List = [[‘Python’, ‘For’] , [‘Programming’]]
print(“\nMulti-Dimensional List: “)
print(List)

Output:

blank List: 
[]

List with the use of String: 
['PythonString']

List containing multiple values: 
Python
Python

Multi-Dimensional List: 
[['Python', 'For'], ['Programming']]

# Creating a List with the use of Numbers Having duplicate values

List = [1, 2, 5, 5, 7, 7, 7, 8, 9]

print(“\nList with the use of Numbers: “)

print(List)

# Creating a List with mixed type of values Having numbers and strings

List = [1, 2, ‘Python’, 6, ‘For’, 8, ‘Python’]

print(“\nList with the use of Mixed Values: “)

print(List)

Output:

List with the use of Numbers: 
[1, 2, 5, 5, 7, 7, 7, 8, 9]

List with the use of Mixed Values: 
[1, 2, 'Python', 6, 'For', 8, 'Python']

 

Python Programs के लिये यहाँ click करें।

 

List List in python List in python in hindi List in python for class 11 List in python for class 12 Python List