Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I have this Json file which I’m using to extract and output the following inf

ID: 3908488 • Letter: S

Question

So I have this Json file which I’m using to extract and output the following info in a python program:

Output:

DEN-ORL

ORL-DEN

LAX-DEN

DEN-LAX

BOS-AUS

AUS-BOS

MIA-LAS

LAS-MIA

And so on..

Someone give me this answer:

Which is good for displaying all the cities but I need the reverse of each city also

displayed

for example:

DEN-ORL

ORL-DEN

What should be the correct code in python3 do it ?

{

"cities": [{

"name": ["DEN","ORL"],

"seats": [

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0]

],

"price": 450

}, {

"name": ["ORL","LAG"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 500

}, {

"name": ["LAX","DEN"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 150

}, {

"name": ["BOS","AUS"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 500

}, {

"name": ["MIA","LAS"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 400

}, {

"name": ["MCI","CLT"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 340

}]

}

{

"cities": [{

"name": ["DEN","ORL"],

"seats": [

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0],

[0, 0]

],

"price": 450

}, {

"name": ["ORL","LAG"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 500

}, {

"name": ["LAX","DEN"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 150

}, {

"name": ["BOS","AUS"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 500

}, {

"name": ["MIA","LAS"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 400

}, {

"name": ["MCI","CLT"],

"seats": [

[0, 1],

[1, 0],

[0, 0],

[0, 1],

[0, 1],

[0, 0],

[0, 1],

[1, 1],

[1, 0],

[0, 0],

[0, 1],

[1, 1],

[1, 1],

[0, 0],

[1, 1],

[1, 0],

[0, 1],

[0, 0],

[0, 0],

[0, 0],

[1, 0],

[1, 1],

[1, 1],

[1, 0]

],

"price": 340

}]

}

Explanation / Answer

import json def main(): filename = input('Enter file name: ') cities = json.load(open(filename, 'r'))['cities'] for city in cities: print('-'.join(reversed(city['name']))) main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote