Capitalize the name

  • Comments posted to this topic are about the item Capitalize the name

  • Nice question, thanks Steve

    Learned something today...

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    β€œlibera tute vulgaris ex”

  • Good question! Can we expect one for proper next? πŸ™‚


    Just because you're right doesn't mean everybody else is wrong.

  • Well, technically speaking none of the answers is correct, because the variable is named

    Username

    which by the way violates PEP8 πŸ˜›

  • How about:

    name.title();

    Wouldn't that work for this one-word example?

     

    • This reply was modified 4 years, 1 month ago by  kaspencer.

    You never know: reading my book: "All about your computer" might just tell you something you never knew!
    lulu.com/kaspencer

  • Rune Bivrin wrote:

    Good question! Can we expect one for proper next? πŸ™‚

    Perhaps you want to write one πŸ™‚

     

    https://www.sqlservercentral.com/contributions

  • kaspencer wrote:

    How about:

    name.title();

    Wouldn't that work for this one-word example?

    Not name.title(), but Username.title() would.

    2020-03-11 09_30_06-cmd - python

  • Wolfram Kraus wrote:

    Well, technically speaking none of the answers is correct, because the variable is named

    Username

    which by the way violates PEP8 πŸ˜›

    Apologies for that. I think the PEP8 violation is the least of my problems with a variable called "Username" (originally) and answers with name.xx(). Both corrected.

     

  • kaspencer wrote:

    How about:

    name.title();

    Wouldn't that work for this one-word example?

    # Python v2.7.13 code:

    str = "this is string example.";

    print str

    print "str.capitalize() : ", str.capitalize()

    print "str.title() : ", str.title()

    $python main.py

    # Results:

    this is string example.

    str.capitalize() : This is string example.

    str.title() : This Is String Example.

    • This reply was modified 4 years, 1 month ago by  George Vobr.
  • Exactly, George, as per my "one word example".

    You never know: reading my book: "All about your computer" might just tell you something you never knew!
    lulu.com/kaspencer

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply