pass 88 and 125 easy
This commit is contained in:
		
							
								
								
									
										25
									
								
								125-240524-pass/main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								125-240524-pass/main.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| def isPalindrome(s: str) -> bool: | ||||
|     tmp = s | ||||
|     tmp = tmp.lower() | ||||
|     def is_char(ch): | ||||
|         if (ch >= 'a' and ch <= 'z') or (ch >= '0' and ch <= '9'): | ||||
|             return True | ||||
|         return False | ||||
|     exp = [] | ||||
|     for lt in tmp: | ||||
|         if is_char(lt): | ||||
|             exp.append(lt) | ||||
|     length = len(exp) | ||||
|     for index, ele in enumerate(exp): | ||||
|         if(exp[index] != exp[length - index - 1]): | ||||
|             return False | ||||
|     return True | ||||
|  | ||||
| s = 'A man, a plan a canal: Panama' | ||||
| print(isPalindrome(s)) | ||||
| s = " " | ||||
| print(isPalindrome(s)) | ||||
| s = "race a car" | ||||
| print(isPalindrome(s)) | ||||
| s = "0P" | ||||
| print(isPalindrome(s)) | ||||
		Reference in New Issue
	
	Block a user