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

Need python program for flie handling for below problem ------------------------

ID: 3907951 • Letter: N

Question

Need python program for flie handling for below problem

---------------------------------------------

Smallest Cargo Name


Thomas is a Leather products Manufacturer and he wanted to deliver few leather goods from Amritsar to Mumbai. He surveyed on many shipping carriers to select the best carrier for his shipment, but having too many options on the list, decided to choose those carriers which has shortest names.


Write a program that will help Thomas identify the carriers with shortest names(consider both lowercase and uppercase) from a list of carrier names in a file and print the output in the console.
Input File : text.txt

This file contains below data

jahan

indigo

go

jaigo

bow


File Input format :
List of cargo names is stored in a file. Find below the sample file.
jahan
indigo
go
jaigo
bow

Console Output Format :
The output is a set of strings seperated by new line, which are essentially the shortest names.

Sample Input 1:(File Content)
Churn
Plank
Slipsheet
Jerrican
Girder
Apsaraa
Jaan
ABC
Jai
Queen   

Sample Output 1:
ABC
Jai


Sample Input 2:(File Content)
jahan
indigo
go
jaigo
bow

Sample Output 2:
go

---------------------------------------------

Explanation / Answer

def main(): file = input('Enter input file name: ') with open(file, 'r') as f: names = [] min_length = float('inf') for line in f: names.append(line.strip()) if len(line.strip())
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