Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Write a program to locate the index location of a number within a given list. For this exercise, use a while loop to iterate

1) Write a program to locate the index location of a number within a given list. For this exercise, use a while loop to iterate through the given List to find the index position of a given number. For example: lst=[10, 99, 98, 85, 45, 100, 59, 65, 66, 76, 12, 35, 13, 100, 80, 95] What is the index location of 100? Result: There is a 100 at index no: 5 There is a 100 at index no: 13

2) Write a program to filter out all empty " strings within a list of strings.

For this exercise, write a function clean_list( list1) where list1 is the list with many " empty strings. This function returns a list without any " components.

lst1=["Tom", "", "Dick", "Harry","", "Here", "", "There", "", "Everywhere"]

In the clean_list(lst1) function:

Create a new list[]

Use a while loop to iterate the list:

If the item is ! ":

Append it to the new list[]

Increment index

Return the new list.

results;

['Tom', '', 'Dick', 'Harry', '', 'Here', '', 'There', '', 'Everywhere']

['Tom', 'Dick', 'Harry', 'Here', 'There', 'Everywhere']

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions