python newbie here. Let's say we have an array wich 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 dont want to code something like:
if 0 <= n[0] and n[1] and ... n[9] <=9:
thanks for your help
Aucun commentaire:
Enregistrer un commentaire