Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, some criticisms:</p> <ul> <li>Don't <em>prompt</em> for arguments, get them from the command line. It makes testing, scripting, and a lot of other things much easier.</li> <li>The implementation you've got wouldn't distinguish, e.g. "the" from "theater"</li> <li>You're using the current-working-directory to pass around the directory you're working on. Don't do this, just use a variable.</li> <li>Someone else said, "use <code>set</code>, it's faster". That advice is incorrect; the correct advice is "use <code>set</code>, because you need a set". A set is a unordered collection of unique items (a list is an ordered collection of not-necessarily-unique items.) As a bonus for using the right collection, your program will probably run faster.</li> <li>You need to properly split up the work you're trying to do. I'll explain:</li> </ul> <p>Your program has two parts: 1. You need to loop through all the files in some directory and rename them according to some rule. 2. The Rule, given a string (yeah, it's going to be a file name, but forget about that), capitalize the first word and all of the subsequent words that aren't in some given set.</p> <p>You've got (1) down pretty pat, so dig further into (2). The steps <em>there</em> are a. knock everything down to lower-case. b. Break the string into words. c. For each word, capitalize it if you're supposed to. d. Join the words back into a string.</p> <p>Write (2) and write a test program that calls it to make sure it works properly:</p> <pre><code>assert capitalizeSongName('the Phantom Of tHe OPERA') == 'The Phantom of the Opera' </code></pre> <p>When you're happy with (2), write (1) and the whole thing should work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload