Question
PLEASE HELP ME FIX THIS CODE. IT DOES NOT SHOW THE LOCATION. Finds the locations of a target value in a list Use: locations =
PLEASE HELP ME FIX THIS CODE. IT DOES NOT SHOW THE LOCATION.
Finds the locations of a target value in a list Use: locations = find_value(num_list, target)
def find_value(num_list, target): locations = [] size = len(num_list) for index in range(size): if target == num_list[index]: locations.append(index)
return locations
num_list = get_string() print() print("{}".format(num_list)) target = int(input("Enter the desired target value: "))
locations = find_value(num_list, target)
print() print("The locations of the target value are: {}".format(locations))
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