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

4. Write a program that open a file named short.txt. The program should the prin

ID: 3607314 • Letter: 4

Question

4. Write a program that open a file named short.txt. The program should the print Short to the console if all of the words have less than 6 letters; otherwise, Not short should be printed to the console. For example: if short.txt contains dog cat hippopotamus bird then when I run this program, Not short should be displayed, whereas if short.txt contains ay bee see dee then when I run this program, Short should be displayed

Explanation / Answer

with open('short.txt', 'r') as f: notShort = False for line in f: words = line.strip().split(' ') for word in words: if len(word) >= 6: notShort = True if notShort: print('Not short') else: print('Short')

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