如何纠正';意外缩进“;Python中的错误?

如何纠正';意外缩进“;Python中的错误?,python,indentation,Python,Indentation,这是我的密码: 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(&

这是我的密码:

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)) 
def c_至f(c):
f=c*(9/5)+32
返回f
c=输入(“请输入摄氏温度:”)
如果c<-273.15:
返回“温度无法达到”
其他:
返回f
打印(“这是你的华氏温度:,c到f(c))
执行此代码时,终端显示:

if c< -273.15:                                                                                                                            
    ^                                                                                                                                         
IndentationError: unexpected indent 
如果c<-273.15:
^                                                                                                                                         
缩进错误:意外缩进

如何继续解决此错误?

需要修复其抛出的回溯线上方的线:

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))
def c_至f(c):
f=c*(9/5)+32
印刷品(f)
在这里,输入行需要缩进以在代码块内保持一致,并且如果您期望值,请考虑添加一个In()。
c=int(输入(“请输入摄氏温度:”)
如果c<-273.15:
打印(“无法达到该温度”)
其他:
印刷品(f)
#print()语句也需要缩进
打印(“这是你的华氏温度:,c到f(c))

看到这一点,它遵循PEP8缩进规则(4个空格)。

这意味着如果c<-273.15:循环缩进时,它不应该
返回f
只是停止所有,我认为这不是一个好函数True,应该使用
print()
以防止函数在到达if/else语句之前结束。