Gadgets 4 Students Career Guide Free Tutorials  Go to Your University  Placement Preparation 
0 like 0 dislike
5.8k views
in JECRC University B.Tech(CSE-IV Sem) Programming With Python Lab by Goeduhub's Expert (7.6k points)
Write a Python function that takes a list and returns a new list with unique elements of the first list.

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.6k points)
edited by
 
Best answer

Ques. Write a Python function that takes a list and returns a new list with unique elements of the first list.

Program-1 :

def f(l):

    x = []

    for a in l:

        if a not in x:

            x.append(a)

    return x

print(f([1,2,3,3,3,3,4,5]))

Output : 

[1,2,3,4,5


Program-2 : 

def f(list):

    a=set(list)

    print(sorted(a))

f([1,1,1,2,3,4])

Output : 

[1,2,3,4]


For more JECRC University CSE-IV Sem Python Lab Experiments CLICK HERE

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

Related questions

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory
...