Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the program will reorder the list so the resulting list is sorted. { array: [ Python, C++, Java, C#, Swift, JavaScript, PHP, C, Perl, VB,

the program will reorder the list so the resulting list is sorted.

{ "array": [ "Python", "C++", "Java", "C#", "Swift", "JavaScript", "PHP", "C", "Perl", "VB", "Kotlin" ] }

expected output :

What is the name of the file? languages.json The values in languages.json are: C C# C++ Java JavaScript Kotlin PHP Perl Python Swift VB

my code:

import json

filename = input('What is the name of the file? ')

with open(filename) as f:

data = json.load(f)

print(len(data['array']))

for i in range(len(data['array']),1,-1):

print(i)

i_check = i

i_largest = i_check

for j in range(len(data['array'])-1,0,-1):

print(j)

if data['array'][j] > data['array'][i_largest]:

i_largest = j

if i_largest != i_check:

data['array'][i_largest],data['array'][i_check] = data['array'][i_check],data['array'][i_largest]

print(data['array'])

could you explain what is wrong with my code

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

Step: 3

blur-text-image

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Identify specific IT applications for HR planning.

Answered: 1 week ago

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago