I am practicing sorting lists to display an alternative output to what the input is.
For Example, I have a list of temperatures and depending on the temperature, I want these to be displayed in a different list, but with the temperatures transformed into letters depending on what the temperature is.
So I have a list of temperatures of 39.3, 38.1, 38.5, 38.4, 39.1, 38.9, 39.5, 39.2 ,38.6, 38.0
I want Python to Print these temperatures as letters in a new list whereby all temperatures below 38.3 to display the letter L, temperatures between 38.3 and 39.2 inclusive to display the letter N and temperatures above 39.2 to display the letter H.
The code I have thus far is as follows:
#problem: add body temperatures to a new list according to temperatures.
#input: a possibly empty list of body temperartures in celcius.
body_temperature = [39.3,38.1,38.5,38.4,39.1,38.9,39.5,39.2,38.6,38.0]
#output: the body temperatures as low, normal or high.
temperature_levels =
for temperature in body_temperature:
levels = temperature + L, N, H
temperature_levels = temperature_levels + [levels]
print (temperature_levels)
I am stuck on how to get Python to transform these temperatures as letters. Any help would be appriciated.