for i in grocery: if i.store_type=="Alcohol" or "Both":(1) This line checks if i.store_type is "Alcohol" or if the string "Both" is Truthy - which it is because it is not '' or None - this if statement will always be True.
if i.store_type=="Alcohol" or i.store_type=="Both":(2) This line checks if the i.store_type is 'Alcohol' or if the i.store_type is 'Both'. This if statement will only be true if the store_type is 'Alcohol' or 'Both'. Regards, Andréas Den ons 28 okt. 2020 kl 12:30 skrev Ashutosh Mishra < [email protected]>: > for i in grocery: > if i.store_type=="Alcohol" or "Both":(1) > if i.store_type=="Alcohol" or i.store_type=="Both":(2) > > can anyone tell me the diffrence between two statements,I am getting two > diffrent results > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/3d26d63e-e725-4074-bbd1-db05e87e402an%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/3d26d63e-e725-4074-bbd1-db05e87e402an%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdt2MKV39E9kfLX7T9spYc_NpEERjKEOrqumriR5r86Ag%40mail.gmail.com.

