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,020 points
4,980 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
• 3,040 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 14, 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
• 3,040 points
1,591 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
• 58,090 points
22,692 views
–1 vote
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,560 points
10,780 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 5, 2019 in Python by Srisha
2,624 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
891 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,058 views
0 votes
1 answer
0 votes
2 answers

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,500 points
12,714 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP