Created
March 22, 2021 08:15
-
-
Save AnisahTiaraPratiwi/7cb4451ceeed9607e19ffd8756051579 to your computer and use it in GitHub Desktop.
The is_palindrome function checks if a string is a palindrome. A palindrome is a string that can be equally read from left to right or right to left, omitting blank spaces, and ignoring capitalization. Examples of palindromes are words like kayak and radar, and phrases like "Never Odd or Even". Fill in the blanks in this function to return True …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_palindrome(input_string): | |
# We'll create two strings, to compare them | |
new_string = "" | |
reverse_string = "" | |
# Traverse through each letter of the input string | |
for string in input_string.lower(): | |
# Add any non-blank letters to the | |
# end of one string, and to the front | |
# of the other string. | |
if string.replace(" ",""): | |
new_string = string + new_string | |
reverse_string = string + reverse_string | |
# Compare the strings | |
if new_string[::-1]==reverse_string: | |
return True | |
return False | |
print(is_palindrome("Never Odd or Even")) # Should be True | |
print(is_palindrome("abc")) # Should be False | |
print(is_palindrome("kayak")) # Should be True |
If a valid email is known to have a mix of characters and numbers and then ends with @edibrige.ng, e.g nnebaba123@edubridge.ng.
Write a functon named is_valid_email that accepts an email as an input argument and then check if the email is valid based on the condition above
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one worked for me
👇🏻