Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function concat_if_digits(string_list) that takes a list of zero or more strings as a parameter and returns a single string obtained by concatenating together

Write a function concat_if_digits(string_list) that takes a list of zero or more strings as a parameter and returns a single string obtained by concatenating together all the strings in 'string_list' that contain any digit characters (i.e., '0' through '9') anywhere within them.

In the example below, the strings that contain digits are '22y', 'bx30' and 'cy99z'. Concatenated together they give '22ybx30cy99z'.

Hint: the string method isdigit might prove useful.

For example:

Test Result
strings = ['abc', '22y', 'bx30', 'x', 'nope', 'cy99z'] print(concat_if_digits(strings))
22ybx30cy99z

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_2

Step: 3

blur-text-image_3

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago