如何解决?因为我只是个新手

问题描述 投票:0回答:1

enter image description here 这是我的错误: 回溯(最近一次调用最后一次): 文件“C:/Users/Admin/AppData/Local/Programs/Python/Python312/code6.py”,第 6 行,位于 如果年龄 < 18: TypeError: '<' not supported between instances of 'str' and 'int'

fix-protocol
1个回答
0
投票

< operator should be applied to either two strings or two integers, so you should cast

age
变量转换为整数:
int(age) < 18

© www.soinside.com 2019 - 2024. All rights reserved.