Frustrated. How can I refer to an index of a string argument??😭😭😭😭(Line 5) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Frustrated. How can I refer to an index of a string argument??😭😭😭😭(Line 5)

https://code.sololearn.com/cNxN65pXqPHN/?ref=app

16th May 2020, 8:57 PM
Timothy Priest
2 Answers
+ 2
if string == string[::-1]
16th May 2020, 9:05 PM
Manoah
Manoah - avatar
+ 1
space =" " def checkstring(string): for n in range(len(string)): if space in string: spaceremover(string ) if string[n]==string[-(n+1)]: print ("palindrome") else: print ("Not a palindrome") def spaceremover(string): Newstring = string.replace(space,"") checkstring (Newstring) while True: yourPalindrome = input("Type a palindrome:") checkstring(yourPalindrome)
16th May 2020, 9:09 PM
Abhay
Abhay - avatar