Book FREE 1:1 Mentorship for Gen AI / Data Science Link 🔗 bit.ly/4d2S2iP
@Ritunj_Gupta8 ай бұрын
Its only fir small letter string it wil not work on like:"Naman" as first letter is capital For this we should just capitalize the original string and reversed string after that it will work on both the cases ✌🏻
@Analyticsvidhya8 ай бұрын
Hi Ritunj, good point you've raised. Here's a recent Python Coding Questions video we have done - where we have covered Palindrome. Link here: kzbin.info/www/bejne/boDTanyDe5aVeac
@jyotirajpoot34983 ай бұрын
Thanks brother 😊
@D.J.PATEL3125 ай бұрын
thanks buddy
@Dabsjd-pn6qp Жыл бұрын
Fantastic
@youngchapo894911 ай бұрын
Hi, could you help explain a little bit about the double colon and -1? Thanks
@Analyticsvidhya11 ай бұрын
```if n == n[::-1]:``` This line checks if the string n is equal to its reverse. In Python, n[::-1] is a slicing operation that creates a reversed copy of the string n. If n is the same as its reverse, it means that it's a palindrome.
@Rahini_Arora10 ай бұрын
But what about upper and lower case Naman this is not a palindrome whereas naman is a palindrome Pls tell complete program
@Analyticsvidhya10 ай бұрын
Good point Rahini. Here's the complete Python code: def is_palindrome(s): # Convert the string to lowercase s = s.lower() # Remove spaces from the string s = ''.join(s.split()) # Check if the string is equal to its reverse return s == s[::-1] # Test the function input_string = input("Enter a string: ") if is_palindrome(input_string): print("It's a palindrome!") else: print("It's not a palindrome.")
@Rahini_Arora10 ай бұрын
@@Analyticsvidhya thanku so much 🙏🏼
@RadhaKrishna-qo7ze24 күн бұрын
Without using [: :-1] Tell
@anandmani150411 күн бұрын
s=input("Enter a string:") u='' 0='' for i in range(-1,-len(s)-1,-1): u+=s[i] for y in range(0,len(s)): o+=s[y] if u==o: print("It is a palindrome") else: print("It is not a palindrome")
@soundaryas9954 Жыл бұрын
n+ means
@DURGAPRASAD-711 ай бұрын
String concatenation
@ankittripathi1364 Жыл бұрын
what does double colon (:: ) mean ? can you please explain?
@Analyticsvidhya Жыл бұрын
This is a representation for reversing characters of a string.