Tuesday, 23 April 2024

LIST METHODES

 

# 1. first creat a List

a = [35,20,32,1,2,3,4,5,3]
print(a)

# 2.  add any value of end of list so

a.append(51)
print(a)

#  3.if you want a sequence of number so

a.sort()
print(a)

# 4. if you want reverse the List so

a.reverse()
print(a)

#  5. if you want count a value in List who many time in list so

print(a.count(3))

#  6. if you want insert a value in replace of value in list so

a.insert(35, 100)
print(a)

#  7. if you want join multipal lists together so

b = [1,2,3,4,5,6]
d = ["manan","hanan"]
b.extend(d)
print(b)

No comments:

Post a Comment

MAKE A CALANDER

  # 1.  convert calander year and month. your choice month or year , print while True :   import calendar   year = int ( input ( "P...