-1

Here is my code:

def c_to_f(c):    
    f = c*(9/5) + 32
    return f
    
c = input("Please enter the temperature in celsius: ")
    if c< -273.15:
        return "That temperature is not achievable."
    else:
        return f
print("Here's your temperature in Fahrenheit: ", c_to_f(c)) 

The terminal, on executing this code displays:

if c< -273.15:                                                                                                                            
    ^                                                                                                                                         
IndentationError: unexpected indent 

How do I proceed to solve this error?

tdelaney
  • 73,364
  • 6
  • 83
  • 116

1 Answers1

0

Need to fix the line above the traceback line it's throwing:

def c_to_f(c):    
    f = c*(9/5) + 32
    print(f)

    # the input line here needs to be indented to be consistent within your code block and consider adding an int() if you are expecting a value
    c = int(input("Please enter the temperature in celsius: "))
    if c < -273.15:
        print("That temperature is not achievable.")
    else:
        print(f)

    # and the print() statement needs to be indented as well 
    print("Here's your temperature in Fahrenheit: ", c_to_f(c))

See this link, it follows the PEP8 rules for indentation (4 spaces).

de_classified
  • 1,927
  • 1
  • 15
  • 19