In this article, you will learn to write a Python Program Create Pandas Series and Display palindrome numbers. This article is very helpful for Python pandas beginners and CBSE Informatics practices class 12 students. So let’s start!
Before going ahead you should know how to create a series. I have already written one article on how to create pandas series. Follow the below-given link to understand the same:
Topics Covered
Python Program Create Pandas Series and Display palindrome numbers – Steps
Follow these steps to write a Python Program Create Pandas Series and Display palindrome numbers.
- Import the pandas module using import pandas as pd
- Declare an empty list and n for the number of elements
- Take a for loop to ask the user to enter n number of elements and append values to the list
- Now create a series from the list created above
- Traverse the list using for loop
- Add logic to display palindrome numbers
Source Code Python Program Create Pandas Series and Display palindrome numbers
import pandas as pd
l=[]
n=int (input ("Enter no. of elements:"))
for i in range (n):
v=int (input ('Enter number to add into list:'))
l.append (v)
s=pd.Series(l)
for i in range (len(s)):
t=s[i]
r=0
while s[i]>0:
r=(r*10)+(s[i]%10)
s[i]//=10
if t==r:
print(t)
Output – Python Program Create Pandas Series and Display palindrome numbers
Watch this video for more understanding:
Follow this link to get more questions on the series.
That’s all from this article, thank you for visit!