Help to solve this
List Operations 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 AND I TRIED THIS WAY if 'a' in "bhupal": print("Match") else: print("NO Match") but failed
11/30/2021 10:12:19 AMBhupal Raut
12 AnswersNew Answer
Task says "search for the character 'a' in an input string." So your code needs to read a string input, and check for character 'a' in the given input string, instead of in a hardcoded string.
You put up top that "No match" should be printed but then in you're code you print "NO Match". Case totally matters
It's probably the prompt. It ends up in the output and may cause a wrong answer
Bhupal Raut , all code coach exercises are tested by a program that passes values for the various test cases and that receives results from the code. this will work perfectly, as long as only the demanded inputs and / or outputs are used in our codes. If we ignore this, we will fail the test cases, even if the code is actually correct.
I just tested your code in Playground and it works. What error you got?
@Ipang can you give it a try
if 'a' in input(): # match else: # no match Try this and let me know
@Ipang if 'a' in input('bhupal'): print("Match") else: print("No Match")
Try x=input() If 'a' in x: print('match') Else: print('no match') The thing is that I don't think you can use input like If 'a' in input()... So try using X=input() If 'a' in input(). X is just a variable, you can swap it out with anything else
@Ipang still error
That's odd. Show me your most recent updated code ...
class virus: virus = True ataca_cerebro = True con_mordida_te_infecta = True def virus(self, activó): self.virus = activó if self.virus: caracter = self.caracter() if self.virus and caracter: return "\nsi te infectas en 60 segundo te conviertes en un zombis\n" elif self.virus and caracter == False: return "si hace ruido atraes a los zombis" else: return "\n cura no hay " def caracter(self): self.comen = "si" self.duermen = "no" self.rompen_todo = "si" if (self.comen == "si" and self.duermen == "no" and self.rompen_todo == "si"): return True else: return False def funcion(self): print("\nvirus mortal => ", self.virus ,"\nataca al cerebro => ", self.ataca_cerebro ,"\ncon mordida te infecta => ", self.con_mordida_te_infecta) print("\nc