Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in Python (no imports, no list comprehension) Write a function that takes in a filepath as a string and writes the number of

Please answer in Python (no imports, no list comprehension)

Write a function that takes in a filepath as a string and writes the number of uppercase and lowercase letters in the entire filepath to the file, in separate lines. This function should return None. Assume the filepath is always valid.

Hint: The filepath is just a string, and you could manipulate/do string operations as usual. The function str.isupper() might be helpful. The filepath provided is also the output file you should write to.

Note: The with open...print... in doctests opens the file you write in and checks if the content is correct. It does not hint towards the question itself.

Example: filepath = 'files/TEST.txt' In the given filepath, bold characters are upper and italic characters are lower, so output file should contain: 4 8

def case_letters(filepath): """ >>> case_letters('files/AlErNaTiNg.txt') >>> with open('files/AlErNaTiNg.txt', 'r') as outfile1: ... print(outfile1.read().strip()) 5 13 >>> case_letters('files/another_test.txt') >>> with open('files/another_test.txt', 'r') as outfile2: ... print(outfile2.read().strip()) 0 19 """

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

1. Which position would you take?

Answered: 1 week ago