Вы можете сделать что-то вроде следующего:
Код:
measurements = []
number = 5
for n in range(number):
m = 0
while not 1 < m < 10:
m = float(input("Enter the measurement result {} (1-10): ".format(n+1)))
measurements.append(m)
if len(measurements) > 1 and abs(measurements[-1]-measurements[-2]) > 1:
break
print(measurements)
Использование:
Enter the measurement result 1 (1-10): 5
Enter the measurement result 2 (1-10): 6
Enter the measurement result 3 (1-10): 20 # Input greater than 10 so ask again
Enter the measurement result 3 (1-10): 7
Enter the measurement result 4 (1-10): 9 # Difference between 7 and 9 greater than 1, so stop.
[5.0, 6.0, 7.0, 9.0]