A string is a sequential object that has zero, one or many characters. This lab asks you to ask the user for a string and then count the number of digits in the string. NOTE: You must do this with a...


Using Python


A string is a sequential object that has zero, one or many characters. This lab asks you to ask the user for a string and then count the<br>number of digits in the string.<br>NOTE: You must do this with a WHILE loop, not a FOR.<br>How can you tell if a character is a digit? If you have a string variable named str, you. can make a Boolean expression that will be True by<br>doing this: str.isdigit() So if I code: str=

Extracted text: A string is a sequential object that has zero, one or many characters. This lab asks you to ask the user for a string and then count the number of digits in the string. NOTE: You must do this with a WHILE loop, not a FOR. How can you tell if a character is a digit? If you have a string variable named str, you. can make a Boolean expression that will be True by doing this: str.isdigit() So if I code: str="spam" then str.isdigit() will be False But if I code: str =. "1984" then str.isdigit( will evaluate to True. The strings will have digits and non-digits mixed. You must look at each character of the string by itself. You do this by indexing the string. If i is an index variable, then str[i] will give you the character at the i-th position in the string (remembering that it is indexed from zero). 320626 2266252 37ay7

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here