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, 2019 in Python by Neel
• 3,010 points
342 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, 2019 by Arvind
• 2,980 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 Jul 13, 2019 by Sheik janibasha
How do I use these functions? Can you give an example?

Related Questions In Python

0 votes
1 answer

How to check whether something is a variable or a function in Python?

Suppose you have a variable defined in ...READ MORE

answered Jul 30, 2019 in Python by Arvind
• 2,980 points
82 views
+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
• 57,530 points
9,323 views
0 votes
2 answers
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, 2019 in Python by Nymeria
• 3,540 points
1,523 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, 2019 in Python by Srisha
112 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, 2019 in Python by Sharan
123 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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 781 views
0 votes
0 answers
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,510 points
2,225 views