+ 1

how it is printing??

in console I wrote print('spams' and 'eggs...') and in output it is only printing eggs... why so?? can anybody explain it

4th Oct 2016, 7:18 AM
Nikhil Ahlawat
Nikhil Ahlawat - avatar
5 Answers
+ 1
and operator first ands the two strings. for and operator, both strings are considered as true. hence it reads both and whichever string read latest is printed. if u try this, print(0 and 'eggs') you will get output as 0. this is because when anding, whatever is anded with 0 will be 0. so string eggs are not read at all. I think you got the answer.
4th Oct 2016, 7:34 AM
Sriniketha
+ 1
thank you @Sriniketha
4th Oct 2016, 7:38 AM
Nikhil Ahlawat
Nikhil Ahlawat - avatar
0
print (Dec 2016)
7th Dec 2025, 1:24 AM
Sydney Stephens
0
Print
7th Dec 2025, 1:24 AM
Sydney Stephens
0
Fghojtuydkeshbmncvzzsde
7th Dec 2025, 1:25 AM
Sydney Stephens