Check whether string contains an integer or not

In this program, we will check whether a string contains an integer or not.

Steps to solve the program
  1. Take input through the user.
  2. Create a variable and assign its value equal to 0.
  3. Use for loop to iterate over each character of the string.
  4. Check if the character in the string is an integer or not using isnumeric().
  5. If it is a number add it to the variable that we have created.
  6. If the value of the variable is greater than 0 then print True, else print False.
				
					a = input("Enter string: ")
count = 0

for char in a:
    if char.isnumeric():
        count += 1
        
if count > 0:
    print(True)
else:
    print(False)
				
			

Output :

				
					Enter string: Python123
True
				
			

check the validity of password

print the following pattern

Leave a Comment