Python isdigit and IsNumeric: Hey hello Everyone this is Rahul from CodingLio. First of all, I would like to thank you for your visits to my post on python string methods. Well, today we are gonna talk about Two of the String Methods i.e Python isdigit and Isnumeric. We will talk about this one by one. If you still have any query, then comment below or Ask that problem in our Programming Community, where professionals will help you. Lets first talk about first string method;
What Does Python isdigit string Method Do?
This method checks whether there are only digits in the given string. If yes then, it prints true otherwise it prints False. This can be helpful for a program many times. you can easily understand this string with the help of a suitable example, here it is;
str = “12345”; # Only digit in this string
str = “i just Love CodingLio”;
and here the output is;
So, what happened in the script above? yes because isdigit founds the Only digit in the first string, As a result it printed True. but in the second String, there were characters with digits, so it just printed False.
What Does Python isnumeric string Method Do?
This string method checks whether any numeric character consists or not. This method is applied to objects with Unicode only. Don’t get me? no need to worry lets head to the Example;
str = u”this20044339″;
str = u”23443444334″;
And look at the output here;
Now, It’s clear that you have understood the concept, Here first string consist both numbers and characters false is printed. But in the second string, there are only numeric characters so the True value is printed.
Today we discussed the Python isdigit and isnumeric string methods with the help of examples. If you really found this helpful don’t forget to share with friends. Hope you enjoyed it Cheers.!!