dimanche 14 janvier 2018

Python while and if problems

I am totally new to python and i have encountered some problems

a= [1,2,5,7,8];
i=0
c=a[i]/2.0;
d=0;
b=len(a);
while i < b:
        if (c).is_integer():
                    i=i+1;
                    d=d +1;         
        else:
                    i=i +1;
print(d);

The answer given to me is 0 but if the firt number on the list even the answer given is 5. Thanks!!

Aucun commentaire:

Enregistrer un commentaire