Python program to check whether a string is palindrome or not

  Рет қаралды 25,138

Analytics Vidhya

Analytics Vidhya

Күн бұрын

Пікірлер: 17
@Analyticsvidhya
@Analyticsvidhya Ай бұрын
Book FREE 1:1 Mentorship for Gen AI / Data Science Link 🔗 bit.ly/4d2S2iP
@Ritunj_Gupta
@Ritunj_Gupta 8 ай бұрын
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 ✌🏻
@Analyticsvidhya
@Analyticsvidhya 8 ай бұрын
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
@jyotirajpoot3498
@jyotirajpoot3498 3 ай бұрын
Thanks brother 😊
@D.J.PATEL312
@D.J.PATEL312 5 ай бұрын
thanks buddy
@Dabsjd-pn6qp
@Dabsjd-pn6qp Жыл бұрын
Fantastic
@youngchapo8949
@youngchapo8949 11 ай бұрын
Hi, could you help explain a little bit about the double colon and -1? Thanks
@Analyticsvidhya
@Analyticsvidhya 11 ай бұрын
```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_Arora
@Rahini_Arora 10 ай бұрын
But what about upper and lower case Naman this is not a palindrome whereas naman is a palindrome Pls tell complete program
@Analyticsvidhya
@Analyticsvidhya 10 ай бұрын
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_Arora
@Rahini_Arora 10 ай бұрын
@@Analyticsvidhya thanku so much 🙏🏼
@RadhaKrishna-qo7ze
@RadhaKrishna-qo7ze 24 күн бұрын
Without using [: :-1] Tell
@anandmani1504
@anandmani1504 11 күн бұрын
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
@soundaryas9954 Жыл бұрын
n+ means
@DURGAPRASAD-7
@DURGAPRASAD-7 11 ай бұрын
String concatenation
@ankittripathi1364
@ankittripathi1364 Жыл бұрын
what does double colon (:: ) mean ? can you please explain?
@Analyticsvidhya
@Analyticsvidhya Жыл бұрын
This is a representation for reversing characters of a string.
Check If A String Is A Palindrome | Python Example
9:01
Portfolio Courses
Рет қаралды 17 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 305 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 50 МЛН
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 43 МЛН
STRING PALINDROME PROGRAM IN PYTHON || PALINDROME CHECK PROGRAM IN PYTHON
7:39
Sundeep Saradhi Kanthety
Рет қаралды 27 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 651 М.
Best Data Science Books for Beginners 📚
16:13
Thu Vu data analytics
Рет қаралды 351 М.
How To Learn Data Science Smartly?
12:13
Krish Naik
Рет қаралды 1,6 МЛН
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 270 М.
L10. Check if a LinkedList is Palindrome or Not | Multiple Approaches
20:02
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 851 М.
Palindrome |  Program to check if a string is Palindrome | Java
9:31
B Tech Computer Science
Рет қаралды 111 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 50 МЛН