Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

12/6/23, 11:40 PM Technology_Sample.

ipynb - Colaboratory

def reverse_string(string):
index = len(string) - 1
reversed_str = ""
while index >= 0:
reversed_str += string[index]
index -= 1
return reversed_str

def remove_spaces(string):
index = 0
no_spaces_str = ""
while index < len(string):
if string[index] != ' ':
no_spaces_str += string[index]
index += 1
return no_spaces_str

def is_palindrome(string):
string = remove_spaces(string)
reversed_str = reverse_string(string)

return string == reversed_str

def main():
print( reverse_string("aeiou") ) # uoiea
print( remove_spaces("ae io ua") ) # aeioua

print( is_palindrome("noon") ) # True


print( is_palindrome("deified") ) # True
print( is_palindrome("go deliver a dare vile dog") ) # True

main()

uoiea
aeioua
True
True
True

https://colab.research.google.com/drive/1pLD7GVWxE4WG8M5j7rkPWNVZxihv0zUI#printMode=true 1/2
12/6/23, 11:40 PM Technology_Sample.ipynb - Colaboratory

https://colab.research.google.com/drive/1pLD7GVWxE4WG8M5j7rkPWNVZxihv0zUI#printMode=true 2/2

You might also like