-1
def number_of_cases(list_data):                     

    i=0
    j=0
    for j in range (len(list_data)):
        for i in range(len(list_data)):
            sum_list = list_data[i] + list_data[j]
            result = print(sum_list, end=' ')
    return result

def main():

    result=number_of_cases(['a','b','a'])

I don't want duplicate results.. how to remove the duplicated values in result.

result: aa ba aa ab bb ab aa ba aa

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
Park Sung
  • 13
  • 1
  • Your output will have no duplicates if you remove duplicates from the input. So you could use something like this: `unique_data = set(list_data); print([a+b for a in unique_data for b in unique_data])` – Matthias Fripp Apr 13 '17 at 19:52

1 Answers1

0
result = list(set(result))

Will remove duplicates (since a set has only unique values) and then return a list like you already have.

Robbie
  • 4,672
  • 1
  • 19
  • 24
  • 1) If this answer were accurate, it would be an extremely common duplicate. 2) It's not accurate. `result` is `None`. – TigerhawkT3 Apr 13 '17 at 03:22