string3 = "abc 123 $$%%"
list1 = string3.split()
print(list1)
for i in list1:
if int(i) > 0:
print("it's a number")
else:
print("not a number")
获得以下错误的数值。想在给定的字符串来搜索蟒蛇
if int(i) > 0:
ValueError: invalid literal for int() with base 10: 'abc'
你认为'int('$$ %%')'应该返回什么? – mshsayem
[请求用户输入,直到他们给出有效响应]的可能重复(https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-响应) – Reti43