In: Computer Science
Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9.
Ex: If the input is: 1995 the output is: yes
Ex: If the input is: 42,000 or any string with a non-integer character, the output is: no
PYTHON 3
# ask the user to input a string
user_string = input("Enter your string : ")
# check whether the input entered by the user have all value as numeric or not
# if all value are numeric then True is stored in Result otherwise False is stored in Result
Result = user_string.isnumeric()
# if the entered string contains all numeric values
if Result == True:
print("yes")
# if the entered string contains at least one non - integer character
else:
print("no")