+ 2

Please correct my 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 --------MY CODE------ search = input() #your code goes here alpha = "a" if "a" in search == "a" in alpha: print("Match") else: print("No match")

22nd Jan 2021, 12:10 PM
Valentine Madzore
11 Respostas
22nd Jan 2021, 12:21 PM
noteve
noteve - avatar
+ 6
if alpha in search: # or if "a" in search:
22nd Jan 2021, 12:14 PM
noteve
noteve - avatar
+ 2
It's still bringing back no match on asd
22nd Jan 2021, 12:18 PM
Valentine Madzore
+ 2
Thank you guys
22nd Jan 2021, 2:41 PM
Valentine Madzore
+ 1
Thanks 👍
22nd Jan 2021, 6:19 PM
Valentine Madzore
+ 1
👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
24th Jan 2021, 8:01 AM
Vrajesh Sulakhe
Vrajesh Sulakhe - avatar
+ 1
s = input() if "a" in s: print("Match") else: print("No match")
14th Nov 2021, 4:29 PM
Aman Verma
Aman Verma - avatar
0
search = input() alpha = "a" if alpha in search: print("Match") else: print("No match")
24th Jan 2021, 7:29 AM
Akhlaque Ahmad
Akhlaque Ahmad - avatar
0
#include<iostream> using namespace std; int firstoccurance(int nums[],int n,int target){ int start = 0; int end = n-1; int mid = start +(end - start)/2; int ans = -1; while (start<=end) { if (target==nums[mid]) { return mid; end = mid-1; }else if (target<nums[mid]) { end = mid-1; } else { start = mid +1; } mid = start +(end - start)/2; } return ans; } int lastoccurance(int nums[],int n,int target){ int start = 0; int end = n-1; int mid = start + (end - start); int ans = -1; while (start<=end) { if (target==nums[mid]) { ans = mid; start = mid+1; }else if (target<nums[mid]) { end = mid -1; } else { start = mid +1; } mid = start + (end - start)/2; } return ans; } int main(){ int nums[10] = {2,5,5,5,6,6}; int index = firstoccurance(nums,10,5); cout<<"The firstoccurance element size is:"<<index<<endl; cout<<"The lastoccurance element size is "<<index<<endl; }
1st Feb 2024, 8:54 AM
Divyanshu Samdani
Divyanshu Samdani - avatar