- 1
I want to display only Ok if item=="Malick". Thanks you sir.
Display ok when item=="Malick" https://code.sololearn.com/c6iEaw599UWB/?ref=app
5 Respostas
+ 3
Malick Diagne ,
are you going to check if "Malick" is a member of the list, we can do:
if "Malick" in ["Doussou","Hamath","Malick"]:
print ("Ok")
else:
print ("I don't see Malick")
+ 3
If you want made that with if/else, you can put:
for item in ["Doussou","Hamath","Malick"]:
if item == "Malick":
print ("Ok")
else:
print ("I don't see Malick")
But if you want made that without if/else, put this:
for item in ["Doussou","Hamath","Malick"]:
pass
print("Ok")
Is the same result.
+ 3
★«Caleb Guerra Ortega»★ ,
the second code in your sample prints also "Ok" even if "Malick" is missing.
for item in ["Doussou","Hamath", "Tom"]:
pass
print("Ok")
result: Ok
+ 3
Lothar
Yes, well, I know that he/she not is the that want.
+ 2
It does output "Ok"? The third line.