首页 > 解决方案 > Python代码只在我运行时说不?

问题描述

我在 repl.it 中对此进行了编码,但它不起作用。谁能告诉我为什么?

import random, sys

mynumber = random.randint(1, 31)
month = 0
print("password cracker 1.0")
username = input("Email: ")
year = input("Year that they were born: ")
while True:
    if month == mynumber and year == 2006:
        print("yes")
        print(month)
        sys.exit(0)
    else:
        print("no")
        month + 1

标签: python

解决方案


您需要比较兼容的类型。任何一个

int(year) == 2006

或者

year == "2006"

"2006"返回的字符串input不等于intvalue 2006


推荐阅读