My Python code does not go through Test Cases | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

My Python code does not go through Test Cases

The given question is: 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. My code: s = input() b = print (a in s) if b True print ("Match") else print ("No Match") You can find the task at the Python course under List operators and then you go to the challenge Build a search Engine

14th Nov 2020, 12:05 PM
Thursday
Thursday - avatar
7 Answers
+ 1
Your code will work after some changes. Compare with your code. s = input() b = 'a' in s if b == True: print ("Match") else: print ("No Match") but you can also in one line: print('Match' if 'a' in input() else 'No Match')
14th Nov 2020, 1:18 PM
Yurii Ostapenko
Yurii Ostapenko - avatar
+ 9
Thursday You're looking for something like this? https://code.sololearn.com/crafynW295I3/?ref=app
14th Nov 2020, 12:13 PM
Simba
Simba - avatar
+ 1
Yes Thanks
14th Nov 2020, 12:17 PM
Thursday
Thursday - avatar
+ 1
Noshin Anwar oh God, why answer a post that is over a year old
3rd Dec 2021, 11:31 AM
Yurii Ostapenko
Yurii Ostapenko - avatar
0
s = input() if "a" in s: print("Match") else: print("No match")
3rd Dec 2021, 6:31 AM
Noshin Anwar
Noshin Anwar - avatar
0
Try this s = input() if "a" in s: print("Match") else: print("No match")
8th Jan 2022, 7:21 PM
Ihor Princ
Ihor Princ - avatar
- 1
WORKS FINE! n = int(input()) result = 0 inputAsString = str(n) inputLength = len(inputAsString) for i in range(inputLength): result += int(inputAsString[i]) print(result)
12th Jul 2021, 9:34 AM
Constantine Tvalashvili
Constantine Tvalashvili - avatar