Please help me regarding this code. Output should be
True#False#True#False#True#
for i in [3,1,4,1,5]:
print()
which function has to be used to print the required output...
note: it is in loop but need only one line output
Please help me regarding this code. Output should be
True#False#True#False#True#
for i in [3,1,4,1,5]:
print()
which function has to be used to print the required output...
note: it is in loop but need only one line output
As I can see from the question we want it to be false wherever 1 is there in the list. Also,To get the output in the same line we need to use end = ' ' in the print statement.
You can try using this code:
for i in [3,1,4,1,5]:
print(i!=1, end='')
which gives an output as: TrueFalseTrueFalseTrue
If the # has to be considered in between the output you can try using this code:
for i in [3,1,4,1,5]:
print(i!=1,'#',end='')
This will give an output as: True #False #True #False #True