def palindrome_checker(a):
if type(a) == "str":
list1 = list(a.split(" "))
elif type(a) == "int":
stringified_a = str(a)
list1 = list(stringified_a)
else:
list1 = a
list2 = list1[::-1]
if list1 == list2:
print("It's a palindrome")
else:
print("It's not a palindrome")
This is an unnecessarily complicated palindrome checking script that covers different user inputs. However, if presented with an int 1234 - it omits the "elif type = int" and "jumps" to else statement, assigns list1 with an int, and the program returns an error, since it's applying indexing to an int.
I tried debugging via "prints" at different stages, and i see that my script detects 1234 as an 'int' but still decides to jump to else, without stringifying the integer.
I'm new to python, and i feel like i'm missing something very obvious here and i'm low key embarrassed but i can't see whats wrong at all...