Quick question, how do you make the values in a list unique? I need to pass a list of numbers into a for loop that multiplies the number to 10 powered to its index and create a list of the answers. I was able to make the program to return the list, however, my code only seems to work for unique numbers and if there are any duplicates it assigns them with the same 10 powered to index.
def expanded_form(num):
y = str(num)
df = list(y)
df.reverse()
print(df)
x = []
product = []
for n in df:
o = pow(10, df.index(n))
x.append(o)
for n1, n2 in zip(x, df):
product.append(str(int(n1) * int(n2)))
product.reverse()
p = [i for i in product if i != '0']
p = [int(i) for i in p]
p.sort(reverse=True)
p = [str(i) for i in p]
print(' + ' .join(p))
when I run this code for a number with repeating numbers like 4982342 it attaches the same values to repeating numbers. here it considers both 4s as 40 and both 2s as 2. how do I get it to consider them separately?
list(set(your_list))