本人小白 请问这个代码那里有问题
digital = input('请输入数字')if bigital == 100:
print('i love you')
print('i hate you')
digital = input('请输入数字')
if digital == "100":
print('i love you')
print('i hate you')
或
digital = input('请输入数字')
digital = int(digital)
if bigital == 100:
print('i love you')
print('i hate you') digital是一个字符串而不是一个整数,所以要么判定的时候把100改为“100”
digital = input('请输入数字')
if digital == "100":
print('i love you')
print('i hate you')
要么加一个int()函数把digital变为整数
digital = input('请输入数字')
if int(digital) == 100:
print('i love you')
print('i hate you')
还有你写这个程序运行起来可能和你预期不太符合,改成这样是不是才对:
digital = input('请输入数字')
if int(digital) == 100:
print('i love you')
else:
print('i hate you') 4楼的应该可以{:10_277:}
页:
[1]