[Python] I am trying to make a degree calculator from farenheit to celsius

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    I keep getting this error:

    "TypeError: can only concatenate str (not "int") to str"
    -----------------------------------------------------------------------------------


    enter image description here

    import math
    temp_input = input(
    'Insert the temperature you would like to convert(100F , 35C for example):')
    unit = temp_input[-1].lower()
    number = temp_input[:-1]

    F_temp = ((( 9 *(number)) + 160) // 5)
    C_temp = (((5 * (number)) - 160) // 9)

    if temp_input[-1:] == 'f':
    print(C_temp)
    elif temp_input[-1:] == 'c':
    print(F_temp)
    else:
    print('try to add C / F , after the numbers !')

    Continue reading...

Compartilhe esta Página