Menu

Someone Make Code Remove Duplicate Numbers First Column Also Obviously Remove Percentage R Q43789005

Can someone make this code not remove the duplicatenumbers in the first column and also obviously not remove thepercentage row but remove all duplicates from the second row and onbut keeping the percentages on the top intact?

Here’s the code:

import xlwt
from xlwt import Workbook
from decimal import *

#create a workbook
wb = Workbook()
#create a sheet
sheet = wb.add_sheet(‘Sheet’,cell_overwrite_ok=True)

#percentages list
percentages = [23.6, 38.2, 50, 61.8, 78.6, 113, 123.6, 138.2,161.8]
#add first row
for i in range(len(percentages)):
    sheet.write(0,i+1,str(percentages[i])+’%’)

#user input
n = int(input(‘Enter number of elements: ‘))
#second row starts from index 1
row=1
print(‘Enter numbers: ‘)
for i in range(n):
     #User input
     val = float(input())
     #Add entered value to first column of therow
     sheet.write(row,0,str(val))
     #calculate each percentage
     prev = “”
     for j in range(len(percentages)):
           result= (percentages[j]/100)*val
          #writeresult to sheet by rounding to nearest whole number using quantizemethod
          current = str(Decimal(result).quantize(Decimal(“1”)))
          if(prev != current):
               sheet.write(row,j+1,current)
               prev = current
#increment the row by 1
row+=1
#save Workbook as xls`
wb.save(‘percentages.xls’)

Thanks to any super hero who helped me!

Expert Answer


Answer to Can someone make this code not remove the duplicate numbers in the first column and also obviously not remove the percen…

OR