Question: Hi, I have the following code: def get_price(str): items = str.split(':') return float(items[1]) def get_month(str): items = str.split('-') return int(items[0]) def get_day(str): items = str.split('-')

Hi, I have the following code:

def get_price(str): items = str.split(':') return float(items[1])

def get_month(str): items = str.split('-') return int(items[0])

def get_day(str): items = str.split('-') return int(items[1])

def get_year(str): items = str.split(':') date_items = items[0].split('-') return int(date_items[2])

def main(): gas_file = open('gas prices.txt', 'r') gas_list = gas_file.readlines() gas_list.sort() print (sorted (gas_list)) main()

I am trying to get it to sort the prices of a "gas list" file by price lowest to highest. Right now its sorting the dates intead. Can you please help me with that? The format of the dates is 04-05-1993:1.068

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!