jeudi 4 novembre 2021

The question is to find if "r" or "R" belongs in a string. Initially i tried the below code [duplicate]

input_str=str(input("enter a word :  " ))
if "r"or"R" in input_str:
    print(input_str,"in red team")
else:
    print("no red team")

but i was getting "in red team for all input"

Then I tried the below code.

input_str=str(input("enter a word :  " ))
if "r" in input_str or "R" in input_str:
    print(input_str,"in red team")
else:
    print("no red team")

I am getting the correct output why is that???

Aucun commentaire:

Enregistrer un commentaire