ITERATING OVER LIST IN PYTHON

GOCOURSE


Iterating Over List

 You can iterate through each list item using loops.


Program:


#remove duplicates number
number_list=[1,2,5,5,3,2,7,4,7,6]
new_list=[]
for
i in
sorted(number_list):
     if
i
not in
new_list:
         new_list.append(i)
print(new_list)



Output:


[1, 2, 3, 4, 5, 6, 7]





More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send