Question: Python 3 Help Write a function named contains_digit() that takes a single parameter to_check as input and returns True if it has at least one
Python 3 Help
Write a function named contains_digit() that takes a single parameter to_check as input and returns True if it has at least one digit in it and False if it contains no digits. Use an indefinite (while) loop and isdigit() function to check whether each character is numeric
Hint: You'll need an additional check in your while loop test condition to make sure you don't go "out of bounds" when grabbing parts of the string to check. In other words, you'll need two conditions in your while loop test condition, joined by an and logical operator. If you think this is better solved with a definite for loop, you'd be right! Feel free to substitute a for loop here if you can figure it out. At your own risk though!
Test cases:
- INST126 --> True
- INST --> False
- pred5 --> True
- fire2 --> True
- FIRE! --> False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
