vendredi 26 janvier 2018

Simple IF statement in Python 2.7

Can someone please help with the IF statement.The syntax seems to be correct and have verified within this forum as well but not sure why is it going inside the "invalid IF statement". Thanks in advance

ips=['20.34.178.250']
for index, item in enumerate(ips):
    flag1 = 0
    host_bytes= item.split('.')
    print item,index
    for index1, item1 in enumerate(host_bytes):
        print item1
        if [item1 > 255 and flag1==0]:
            print "IP Address is invalid",item1,flag1
            flag1=1
print flag1

Output :

20.34.178.250 0
20
IP Address is invalid 20 0
34
IP Address is invalid 34 1
178

IP Address is invalid 178 1 250 IP Address is invalid 250 1 1

Process finished with exit code 0

Aucun commentaire:

Enregistrer un commentaire