ABS Python 08.03

Podrzucam dzisiejszy ko艅cowy kod:

"""
1. dla kazdej wartosci z listy temps_fahrenheit przekonwertowac ja do skali celsjusza
2. dla kazdej wartosci z listy temps przekonwertowac do kelvina:
    a. stworzenie 3ech list: K; C; F
    b. usun膮膰 litery ze string贸w
    b*. przekonwertowa膰 ze str na int
    c. przekonwertowa膰 integery z list na Kelviny
    d. po艂膮czy膰 w jedn膮 list臋
"""
def fahrenheit_to_celsius(fahrenheit):
    celsius = (fahrenheit - 32) / 1.8
    return celsius

def fahrenheit_to_kelvin(fahrenheit):
    kelvin = (fahrenheit - 32) * 5/9 + 273.15
    return kelvin

def celsius_to_kelvin(celsius):
    kelvin = celsius + 273.15
    if kelvin < 0:
        raise Exception("Kelvin cannot be lower than 0!")

    return kelvin

temps_fahrenheit = [12, 101, 23, 89, 21, 839, 104, 99]
temps = ["12C", "101F", "23K", "89C", "21K", "839F", "104C", "99F"]
#temps_celsius = []

temps_K = []

for single_temp in temps:
    if single_temp[-1] == "F":
        temps_K.append(fahrenheit_to_kelvin(int(single_temp[:-1])))
    elif single_temp[-1] == "C":
        temps_K.append(celsius_to_kelvin(int(single_temp[:-1])))
    elif single_temp[-1] == "K":
        temps_K.append(int(single_temp[:-1]))
    else:
        raise Exception("Wrong data type")


print(f"temps_K = {temps_K}")


#
# for single_temp in temps_fahrenheit:
#     celsius = fahrenheit_to_celsius(single_temp)
#     temps_celsius.append(celsius)
# print(temps_celsius)