For python 3.4.1, how would you go about finding if certain characters are in your string? I tried doing it this way:
def isItBinary(myString):
for ele in myString:
if ele == '1' or if ele == '0':
return True
else:
return False
The problem with this code is that if I type isItBinary('102'), it will return True. I just want it to return True if and only if it contains '1' or '0'.
Aucun commentaire:
Enregistrer un commentaire