Thanks for reaching out on Microsoft Q&A.
To extract unique values from a list in Python without using built-in functions, you can use a simple loop to check for duplicates. Here’s how you can do it:
A = [1, 2, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 5]
B = []
for item in A:
if item not in B:
B.append(item)
print(B) # Output: [1, 2, 3, 4, 5]
Explanation:
- Initialize an empty list
B
to store unique values. - Loop through each item in list
A
. - Check if the item is not already in
B
. If it’s not, append it toB
. - Finally, print
B
to see the unique values.
This method effectively builds a new list of unique items without using any built-in functions
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.