
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Verify Kth Index Element in Python
Input − Assume, you have a Series,
a abc b 123 c xyz d ijk
Solution
To solve this, we will follow the steps given below −
Define a Series
Get the index from user
Set the if condition to check the value is digit or not. It is defined below,
if(data[x].isdigit()): print("digits present") else: print("not present")
Example
Let us see the following implementation to get a better understanding.
import pandas as pd dic = {'a':'abc','b':'123','c':'xyz','d':'ijk'} data = pd.Series(dic) x = input("enter the index : ") if(data[x].isdigit()): print("digits present") else: print("not present")
Output
enter the index : a not present enter the index : b digits present
Advertisements