MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/shittyprogramming/comments/hdcm66/aigenerated_python_code/fvlnxx1/?context=3
r/shittyprogramming • u/minimaxir • Jun 21 '20
26 comments sorted by
View all comments
Show parent comment
5
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?
all(int(c) for c in s)
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.
4
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.
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 toint?