Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use the Python Language, preferabally 2.7, to solve this two probem set about while loops. The parameters and answer template for the solution is
Please use the Python Language, preferabally 2.7, to solve this two probem set about while loops. The parameters and answer template for the solution is also given beneath the problem descriptions.
Problem 1: | Write code to remove every odd number from a list. For example, the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] would yield [2, 4, 6, 8, 10].You may not use any built-in functions/methods besides len() and .append(). |
Problem 2: | Write code that takes two strings from the user, and finds the index of the second string inside the first. For example, happybirthhappyday and happy yields the result 10. If the substring is not in the string more than once, your code should return -1. |
#PROBLEM 1 def removeOdd(l1): list1 = l1 #YOUR CODE GOES HERE (indented) return l1 #END YOUR CODE
#PROBLEM 2 def getSecond(l1,l2): string1 = l1 string2 = l2 #YOUR CODE GOES HERE (indented) return string1 #END YOUR CODE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started