0

I need to write a function that given a list of numbers, returns only the unique numbers less than 100. The function should take a list as input. The function should return a list of the unique numbers from the input list, that are less than 100. For example- if my function is called unique_numbers, and I call it like this: result = unique_numbers([3,3,54,55,1,34,5,134,34]) it should return this: [1,3,5,34,54,55] can anyone help?

I have a function that will give me back numbers less than 100 but I cant figure out how to combine that with a function that will give me unique numbers as well.

def unique_numbers (list_one):
  list_unique = list []
  for i in range (len(list_one)):
    if list_one [i] < 100
      list_unique.append (list_one [i])
  return list_unique

list_one:[1,1,110,40,30,3,4,5,5]

ldamp
  • 1
  • 1
    Convert the list to a set and then convert it back to a list. Since set elements are unique, this will remove all the duplicates. – Barmar Nov 11 '22 at 00:08

0 Answers0