I want an explain to this labeling code | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 3

I want an explain to this labeling code

You are building a search system and need to search for the character 'a' in an input string. Output "Match" if 'a' is found in the string, and "No match" if it's not. Sample Input great Sample Output Match When i run it only the "No match" was work and the "Match" was not work Can anyone tell me why and if he can write the right that will be awesome :) My code -》 s = input() #your code goes here items=['A','a'] if items in s : print("Match") else : print("No match")

31st Dec 2020, 7:27 PM
XLK
XLK - avatar
4 Réponses
+ 7
It says to check for "a" only so I don't get why are you checking for "A" as well? And also the line "if items in s" is equivalent to searching a list (["A","a"] ) in the input ,is that what you need to find here? According to question it should be simply as following: if "a" in s: print("Match") else: print("No match")
31st Dec 2020, 7:33 PM
Abhay
Abhay - avatar
+ 3
thank you my problem was solved
31st Dec 2020, 9:18 PM
XLK
XLK - avatar
+ 1
s = input() if 'a' in s: print('Match') else: print('No match') 😊👍
27th Dec 2021, 2:14 PM
Emmanuel Francis
Emmanuel Francis - avatar
0
123
21st Apr 2021, 8:47 AM
Henri Kouadio
Henri Kouadio - avatar