python中的if / else语句

时间:2019-07-18 06:25:35

标签: python

我在使用If / Else语句时遇到麻烦,在尝试打印该语句时一直给我一个错误。这是一个输入值。

我尝试根据Python中正确的if / else语句设置其格式,但没有给我期望的值。

height = input ('What is your height')

if  height<160:
    print ('S')
elif height>160:
    print ('M')
else:
    print ('L')

Error message being displayed: 

What is your height25
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-a97ac4d9ac5b> in <module>
      1 height = input ('What is your height')
      2 
----> 3 if  height<160:
      4     print ('S')
      5 elif height>160:

TypeError: '<' not supported between instances of 'str' and 'int'

0 个答案:

没有答案