Say I have a list of numbers. How would I do to check that every item in the list is an int?
I have searched around, but haven't been able to find anything on this.
for i in myList:
result=isinstance(i, int)
if result == False:
break
would work, but looks very ugly and unpythonic in my opinion.
Is there any better(and more pythonic) way of doing this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…