Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions