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

Can anyone help me figure this out in Python? Write a program to read the file N

ID: 3805762 • Letter: C

Question

Can anyone help me figure this out in Python?

Write a program to read the file NYC1-funnynames.txt into a list, by completing the function provided. sort the list of names print the list of names one name per line. Program output: Alma Frienzergon Kent Belevit Mitch Again Oliver Stuffismisson Sandi Shores Sarah Bellum Willie Pas-D' course Yolanda Ismyland # this function reads from "NYC-funnynames.txt" places the names in a List. # program should return a List of names def read_names (): names = [] #todo write code here # TODO: MAIN PROGRAM HERE (caLL read_names, sort names, then print names)

Explanation / Answer

def read_names():
   f = open("NYC1-funnynames.txt",'r')
   names = []
   for line in f.readlines():
       line = line[0:-1]
       names.append(line)
   names.sort()
   return names
q = read_names()
print(q)

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