gpt4 book ai didi

python - 如何在 Python 中比较字符串和整数?

转载 作者:行者123 更新时间:2023-11-28 20:41:12 24 4
gpt4 key购买 nike

<分区>

我是 Python 的新手。当我在输入中输入一个字母时,我写了这个并得到了这个错误:

TypeError: unorderable types: str() >= int()

这是我写的代码:

user_input = input('How old are you?: ')
if user_input >= 18:
print('You are an adult')
elif user_input < 18:
print('You are quite young')
elif user_input == str():
print ('That is not a number')

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com