Python newbie here. Let's say we have an array which contains 10 random integers. I want to check if each value of the integers is 0<= x <= 9. So for example somehow like this:
if 0 <= n[:11] <=9:
print('correct')
'n[:10]' is treated like a list so I can't compare it with 0 and 9. Is there an elegant way to check the range of items in that array?
I don't want to code something like:
if 0 <= n[0] and n[1] and ... n[9] <=9:
thanks for your help
all(0 <= i <= 9 for i in n[:11])…