Feb-21-2023, 01:04 PM
Not sure why round is not working for you. I made up some data for list1 and list2 and ratio. Your version as posted:
do for item in list1 and change the subsequent code, but will leave to you.
list1 = [2.2,6.1,7.7,10] list2 = [12.345,23.456,34.567,5] ratio = 3.1415926535 items = len(list1) for n in range (0,items,1): print("\t\t\t",(list1[n]),end = "\t\t\t\t") print((float(list1[n]) * ratio),("\t"),list2[n])
Output: 2.2 6.911503837700001 12.345
6.1 19.16371518635 23.456
7.7 24.19026343195 34.567
10 31.415926535 5
Now, properly put round list1 = [2.2,6.1,7.7,10] list2 = [12.345,23.456,34.567,5] ratio = 3.1415926535 items = len(list1) for n in range (0,items,1): print("\t\t\t",round(list1[n],2),end = "\t\t\t\t") print(str(round(float(list1[n]) * ratio,2))+"\t"+str(+round(list2[n],2)))
Output: 2.2 6.91 12.35
6.1 19.16 23.46
7.7 24.19 34.57
10 31.42 5
There are a number of other issues in your code snippet - the range operator for one could be dropped back to range(items), or even betterdo for item in list1 and change the subsequent code, but will leave to you.