hey this question isn't included in my homework but python is a part of my class so i hope it falls under this context but:
on my laptop i use pthon version 3 and ive been doing extra exercises on the topic and ive come across a problem that i dont quite understand and that involves reversing a string as a list to see if its writen the same backwards, this is what i came up with:
any solutions to why [::-1] doesn't work, im not really looking for other ways to reverse a string just why it doesnt work this way... thanks in advance ^^
westbob
on my laptop i use pthon version 3 and ive been doing extra exercises on the topic and ive come across a problem that i dont quite understand and that involves reversing a string as a list to see if its writen the same backwards, this is what i came up with:
1 2 3 4 5 6 7 |
def palindrome(): a = [ input ( "palindrome? : " )) print (a[:: - 1 ]) #just to see if a[::-1] actually reverses "a" (for some reason it doesn't) if a = = a[:: - 1 ]: print ( "yes" ) else : print ( "no" ) |
westbob