samedi 16 mars 2019

what is difference between and and & in if condition in python

temp = [-1,1]
first_value = abs(temp[0])
last_value = abs(temp[-1])

if first_value == last_value and sum(temp) == 0 and len(temp) >= 1 :
   print("hurray")

my code's o/p:

hurray

if first_value == last_value & sum(temp) == 0 & len(temp) >= 1 :
       print("hurray")

1)I have replaced and with symbol, than it never showed be any output nor error

2)what is difference between and symbol of and why it worked while using and , failed using the symbol (&)

3) Any difference is execution and what is best to use

Aucun commentaire:

Enregistrer un commentaire