Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
860 B
3
Indexable
Never
def is_palindrome(s: str) -> bool:
    
    s = s.lower()
    s = ''.join(c for c in s if c.isalnum())
    return s == s[::-1]


print(is_palindrome('racecar')) 
print(is_palindrome('hello'))    
print(is_palindrome('A man a plan a canal Panama'))







def is_power(a: int, b: int) -> bool:
   
    if a == 0:
        return False
    while a % b == 0:
        a = a // b
    return a == 1 or a == b


print(is_power(8, 2))  
print(is_power(27, 3))  
print(is_power(1024, 4)) 
print(is_power(12, 3))  
print(is_power(343, 7)) 
print(is_power(256, 6)) 








def print_string_length(s: str) -> None:
    
    count = 0
    for char in s:
        count += 1
    print(f'Length: {count:>10}{s}')

# Example usage:
print_string_length('hello') 
print_string_length('Python')
print_string_length('programming') 
Leave a Comment