취미생활/CheckIO

[checkIO]Element 05.Secret Message

우주먼지의하루 2020. 3. 1. 11:04
728x90

"Where does a wise man hide a leaf? In the forest. But what does he do if there is no forest? ... He grows a forest to hide it in."
-- Gilbert Keith Chesterton

 

Ever tried to send a secret message to someone without using the postal service? You could use newspapers to tell your secret. Even if someone finds your message, it's easy to brush them off as paranoid and as a conspiracy theorist. One of the simplest ways to hide a secret message is to use capital letters. Let's find some of these secret messages.

 

You are given a chunk of text. Gather all capital letters in one word in the order that they appear in the text.

For example: text = "How are you? Eh, ok. Low or Lower? Ohhh.", if we collect all of the capital letters, we get the message "HELLO".

 

Input: A text as a string (unicode).

Output: The secret message as a string or an empty string.

 

Example:

find_message("How are you? Eh, ok. Low or Lower? Ohhh.") == "HELLO"

find_message("hello world!") == ""

 

* 대문자로 숨겨진 알파벳을 확인해라 !

 

 

 

- 풀이

 

def find_message(text: str) -> str:
    result = ''
    for i in text:
        if i.isupper() == True:
            result = result + i
    return result

 

 

반응형

'취미생활 > CheckIO' 카테고리의 다른 글

[checkIO]Element 07.Even the Last  (0) 2020.03.07
[checkIO]Element 06.Fizz Buzz  (0) 2020.03.03
[checkIO]Element 04.Digits Multiplication  (0) 2020.02.26
[checkIO]Element 03.Index Power  (0) 2020.02.24
[checkIO]Element 02.Easy Unpack  (0) 2020.02.22