How to check whether a string contains alphabets or number in Python?

0 votes
I want to know if there is a function in Python to know whether a string contains alphabets or numbers. Any help would be appreciated.
Jul 12 in Python by Neel
• 1,610 points
30 views

2 answers to this question.

0 votes
There is a method in python isalpha() to check this. For example,

>>> string = "arvind123"
>>> for char in string:
...     print char, char.isalpha()
...
a True
r True
v True
i True
n True
d True
1 False
2 False
3 False
answered Jul 12 by Arvind
• 1,530 points
+1 vote
By using isAlpha () to check whether the string is alphet or not.
By using isNum () to check given string numeric value or not.
answered 6 days ago by Sheik janibasha

Related Questions In Python

+1 vote
1 answer

How to check if a string is null in python

Try this: if cookie and not cookie.isspace(): # the ...READ MORE

answered Aug 20, 2018 in Python by Priyaj
• 56,160 points
1,591 views
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

answered Feb 12 in Python by Nymeria
• 3,500 points
39 views
0 votes
1 answer

How to check if a string ends with a character in python?

You can use the endswith method. It checks ...READ MORE

answered Apr 4 in Python by Srisha
39 views
0 votes
1 answer

How to check if a substring is present in a string using Python?

To check if the substring exists in ...READ MORE

answered May 9 in Python by Sharan
31 views
0 votes
1 answer

How to check if a given string matches a particular pattern in Python?

You can use re module of python ...READ MORE

answered Jul 3 in Python by Neel
• 1,610 points
18 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
259 views