Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago

Question

What are the types of forms of communication ?

Answered: 1 week ago

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago