This document provides instructions and code for a program that checks if a string entered by a user represents a valid integer. The program takes a string as input, and uses the isdigit() string method to check if every character is a digit from 0 to 9. It will print "yes" if so, or "no" if any character is invalid for an integer.
This document provides instructions and code for a program that checks if a string entered by a user represents a valid integer. The program takes a string as input, and uses the isdigit() string method to check if every character is a digit from 0 to 9. It will print "yes" if so, or "no" if any character is invalid for an integer.
This document provides instructions and code for a program that checks if a string entered by a user represents a valid integer. The program takes a string as input, and uses the isdigit() string method to check if every character is a digit from 0 to 9. It will print "yes" if so, or "no" if any character is invalid for an integer.
This document provides instructions and code for a program that checks if a string entered by a user represents a valid integer. The program takes a string as input, and uses the isdigit() string method to check if every character is a digit from 0 to 9. It will print "yes" if so, or "no" if any character is invalid for an integer.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 1
6.
5 LAB Checker for integer string
Instructor note: Note: this section of your textbook contains activities that you will complete for points. To ensure your work is scored, please access this page from the assignment link provided in Blackboard. If you did not access this page via Blackboard, please do so now. 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:
user_string = input()
print(“yes”) if user_string.isdigit() else print(“no”)