r/shittyprogramming • • Jun 21 '20

AI-generated Python code

Post image
504 Upvotes

26 comments sorted by

View all comments

Show parent comment

5

u/murtaza64 Jun 22 '20

all(int(c) for c in s) won't work as expected right? You'll get a TypeError or ValueError for characters that can't be cast to int?

4

u/ollien Jun 22 '20

Yeah, this will return True if all values convert to non-zero integers. You'd have to catch the ValueError somewhere to check if something is an integer.