为什么不是';在if语句中调用的函数是什么?(python)

为什么不是';在if语句中调用的函数是什么?(python),python,function,if-statement,Python,Function,If Statement,我最近开始学习编程,尤其是python。我是一个完全的初学者,我开始在我的第一个小项目转换英寸和磅的工作。我不明白为什么函数没有在if语句中被调用。请帮忙!谢谢 # Convert inches to centimeters and pounds to kilograms # Converts inches to centimeters def convic(): amti = raw_input("How many inches? **Integers only!** ")

我最近开始学习编程,尤其是python。我是一个完全的初学者,我开始在我的第一个小项目转换英寸和磅的工作。我不明白为什么函数没有在if语句中被调用。请帮忙!谢谢

# Convert inches to centimeters and pounds to kilograms


# Converts inches to centimeters
def convic():
    amti = raw_input("How many inches? **Integers only!** ")
    if amti.isdigit():
        amti = int(float(amti))
        centi = amti * 2.54
        print "%d inches equals %d centimeters." % (amti, centi)
    else:
        print "Sorry that is not a number and/or integer."

# Converts pounds to kilograms  
def convpk():   
    amtp = raw_input("How many pounds? **Integers only!** ")
    if amtp.isdigit():
        amtp = int(float(amtp))
        kilo = amtp * 0.45359
        print "%d pounds equals %d kilograms." % (amtp, kilo)
    else:
        print "Sorry that is not a number and/or integer."

answer = raw_input("Would you like to convert inches to centimeters or    pounds to kilograms? ")   
if answer == "inches to centimenters":
    convic()
if answer == "pounds to kilograms":
    convpk()

# Not a correct response        
else:
    while answer != "inches to centimeters" and "pounds to kilograms":
        answer = raw_input("Sorry please enter inches to centimeters or  pounds to kilograms. ")
        if answer == "inches to centimenters":
            convic()
        if answer == "pounds to kilograms":
            convpk()

这一行不是您想要的:

应答时!=“英寸到厘米”和“磅到千克”:

我想你想要:


应答时!=“英寸到厘米”并回答!=“磅到千克”:

你似乎把厘米拼错了。
如果你纠正了这一点,那么它应该可以工作。

你有很多If语句,是不是有一个特别的语句导致了这个问题?@user3636636所有包含convic()或convpk()的语句@James我的程序没有执行convic()或convpk(),我只是不知道我做错了什么“英寸到厘米”:额外的nAlso,