For this lab, I need to write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, adjust each integer in the list by subtracting the smallest value from all the integers. My code runs and I am getting the correct outputs, but the code is meant to output the new integers(after subtracting the smallest value) in the order they were inputted. However, because I sorted the list in the beginning of my program, the numbers are printing in order from smallest to biggest. How do I get them to print in my final statement in the same order that they were inputted? For example, if the numbers inputted were 30, 50, 10, 70, 65, they should output 20, 40, 0, 60, 55. But my program is outputting them as 0, 20, 40, 55,60.
This is the code I have so far:
x = int(input('Enter the number of integers in the data set: ')) print('Enter the', x, 'numbers: ') list = [] for i in range(x): x = int(input()) list.append(x) list.sort() smallest = list[0] print('The smallest value is:', smallest) print('The normalized data set is:') for num in list: print(num - smallest)