Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

STUCK ON A PART OF MY CODE '''Uses a binary search to locate rainfall amounts in mm from the supplied list of dictionaries. target is

STUCK ON A PART OF MY CODE

'''Uses a binary search to locate rainfall amounts in mm from the supplied list of dictionaries. target is a date in the 'yearmonth' value format. The function assumes that the list has been sorted by increasing date. The function will raise a ValueError exception if the year and month in target do not exist in allData.''' low = 0 high = len(allData) - 1 while low <= high : mid = (low + high) // 2 if target < allData[mid] : high = mid - 1 elif target > allData[mid] : low = mid + 1 else: return mid raise ValueError("Invalid")

Everytime I run this code, an error message pops up saying ' < not support between instances of 'int' and 'dict'. The problem is at 'target < allData[mid]' but I can't figure out how to fix it.

Thank you!

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Design a health and safety policy.

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago