I'm asking you a question because I thought of it while I was learning Python by myself.
When you enter an English name without spacing as follows
RyuHyunJin
as follows
[Ryu, Hyun, Jin]
is about to be output.
if
When lowercase letters come in, you can attach them to the left letter and capital letters to the left, but it's hard to find an example of a function related to upper and lowercase letters. Please help me
A frustrating answer: If you use a regular expression, it's a story that ends in Hankyu.
import re
# Matches when one or more non-capitalized characters appear once capitalized
regex = r"[A-Z][^A-Z]+"
test_strs = ("RyuHyunJin", "Gwang-hyunKim")
for s in test_strs :
print(' '.join(re.findall(regex, s)))
A more sincere answer:
Of course, it's also important to branch out to if
to determine whether "this letter is capitalized or not." (Note, there's a function called ord()
.)
But more importantly, the key idea is that you have to go around a given string by letter.
This is what happens in Python.
for letter in "RyuHyunJin" :
print(letter) # Imagine what will be printed and then run it.
Try it yourself from here.
If you make it very, very easy...
Case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Input = "HyunJinRyu"
Output = ""
Enter for letter in:
If letter in uppercase:
Output +=""
Output + = characters
print (output)
Apply it and make it better.
614 PHP ssh2_scp_send fails to send files as intended
1132 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
673 M2 Mac fails to install rbenv install 3.1.3 due to errors
688 Error in x, y, and format string must not be None
772 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2025 OneMinuteCode. All rights reserved.