- 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

6th Nov 2021, 11:59 AM
Malick Diagne
Malick Diagne - avatar
5 Respuestas
+ 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")
6th Nov 2021, 12:46 PM
Lothar
Lothar - avatar
+ 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.
6th Nov 2021, 1:19 PM
CGO!
CGO! - avatar
+ 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
6th Nov 2021, 2:20 PM
Lothar
Lothar - avatar
+ 3
Lothar Yes, well, I know that he/she not is the that want.
6th Nov 2021, 4:15 PM
CGO!
CGO! - avatar
+ 2
It does output "Ok"? The third line.
6th Nov 2021, 12:04 PM
你知道規則,我也是
你知道規則,我也是 - avatar