Skip to the content

The name, written right

Problem

People type their name however it comes out: aNN, PETER, lucy. Write a function that takes a name (at least one letter) and returns it with the first letter uppercase and everything else lowercase:

with "aNN" you return "Ann".

If the name is a single letter, you return that letter in uppercase.

Examples

  • "aNN" → "Ann"

  • "PETER" → "Peter"

  • "lucy" → "Lucy"

  • Already written right

    "Grace" → "Grace"

Besides these, the challenge has hidden tests that are revealed when you submit your solution.

You start with this

Python

def name_case(name):
    pass

JavaScript

function nameCase(name) {
}
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →