Trouble with if in python

后端 未结 4 1464
刺人心
刺人心 2021-01-24 01:36

Hey just starting to learn python and got some problems already I made a code with an if statement It should work but it isn\'t working can someone fix it and tell me what I did

4条回答
  •  余生分开走
    2021-01-24 01:52

    raw_input() returns a string but you are comparing x and y with integers.

    Turn y into a integer before comparing:

    y = int(y)
    if y >= 50 and y <= 100:
    

    You can simplify your comparison a little with chaining, letting you inline the int() call:

    if 50 <= int(y) <= 100:
    

提交回复
热议问题