0

how to check if there is "A1" sequence somwhere in string?

e.g: if string = "A1BBD5" then it should return True else False because ithas "A1" or if string = "BOOEZP4HTIN3G3WMLQ1M7FMB" it should return False because there is no "A1".

15th Apr 2019, 2:07 PM
Bikal Shrestha
1 Antwort
+ 2
string = “A1BBD5” pattern = “A1” if pattern in string: print(‘Found it!’) or simple print(pattern in string) or as a function def check(string, pattern): return pattern in string
15th Apr 2019, 2:20 PM
Mike Buttery
Mike Buttery - avatar