str.isalnum()<\/strong><\/p>\n\n\n\nThis method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9).<\/p>\n\n\n\n
>>> print 'ab123'.isalnum()\nTrue\n>>> print 'ab123#'.isalnum()\nFalse<\/pre>\n\n\n\nstr.isalpha()<\/strong><\/p>\n\n\n\nThis method checks if all the characters of a string are alphabetical (a-z and A-Z).<\/p>\n\n\n\n
>>> print 'abcD'.isalpha()\nTrue\n>>> print 'abcd1'.isalpha()\nFalse<\/pre>\n\n\n\nstr.isdigit()<\/strong><\/p>\n\n\n\nThis method checks if all the characters of a string are digits (0-9).<\/p>\n\n\n\n
>>> print '1234'.isdigit()\nTrue\n>>> print '123edsd'.isdigit()\nFalse<\/pre>\n\n\n\nstr.islower()<\/strong><\/p>\n\n\n\nThis method checks if all the characters of a string are lowercase characters (a-z).<\/p>\n\n\n\n
>>> print 'abcd123#'.islower()\nTrue\n>>> print 'Abcd123#'.islower()\nFalse<\/pre>\n\n\n\nstr.isupper()<\/strong><\/p>\n\n\n\nThis method checks if all the characters of a string are uppercase characters (A-Z).<\/p>\n\n\n\n
>>> print 'ABCD123#'.isupper()\nTrue\n>>> print 'Abcd123#'.isupper()\nFalse<\/pre>\n\n\n\n<\/span>Task<\/strong><\/span><\/h2>\n\n\n\nYou are given a string S<\/strong>.<\/p>\n\n\n\nYour task is to find out if the string S<\/strong> contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters.<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nA single line containing a string S<\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n0 < len(S) < 1000<\/strong><\/p>\n\n\n\n<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\n- In the first line, print True if S<\/strong> has any alphanumeric characters. Otherwise, print False.<\/li>
- In the second line, print True if S<\/strong> has any alphabetical characters. Otherwise, print False.<\/li>
- In the third line, print True if S<\/strong> has any digits. Otherwise, print False.<\/li>
- In the fourth line, print True if S<\/strong> has any lowercase characters. Otherwise, print False.<\/li>
- In the fifth line, print True if S<\/strong> has any uppercase characters. Otherwise, print False.<\/li><\/ul>\n\n\n\n
Sample Input<\/strong><\/p>\n\n\n\nqA2<\/pre>\n\n\n\nSample Output<\/strong><\/p>\n\n\n\nTrue\nTrue\nTrue\nTrue\nTrue<\/pre>\n\n\n\n<\/span>Solution – String Validators in Python – Hacker Rank Solution <\/strong><\/span><\/h2>\n\n\n\nif __name__ == '__main__':\n s = input()\n print(any(map(str.isalnum, s)))\n print(any(map(str.isalpha, s)))\n print(any(map(str.isdigit, s)))\n print(any(map(str.islower, s)))\n print(any(map(str.isupper, s)))<\/pre>\n\n\n\n