Skip to content

Instantly share code, notes, and snippets.

@johannchopin
Last active November 4, 2017 17:42
Show Gist options
  • Save johannchopin/82d1a2c652026600f806cb2b79e155eb to your computer and use it in GitHub Desktop.
Save johannchopin/82d1a2c652026600f806cb2b79e155eb to your computer and use it in GitHub Desktop.
LOWER_CASE_TO_CAPITAL = ord('a') - ord('A')
def my_title(title):
acc = ""
previous_letter = ""
for letter in title:
if ("a" <= letter <= "z") and not("a" <= previous_letter <= "z") and not("A" <= previous_letter <= "Z"):
letter = chr(ord(letter) - LOWER_CASE_TO_CAPITAL)
previous_letter = letter
acc += letter
return acc
@laowantong
Copy link

Version très claire, et que je préfère même à la mienne (cf. commentaires du code d'Alexandre). Bravo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment