Develop/파이썬 (Python)

[Python] [중급] 파이썬 예제 뽀개기 | 김왼손의 왼손코딩

안다희 2019. 2. 7. 02:43
728x90

https://www.youtube.com/watch?v=POOMczpRo6M&index=4&list=PLGPF8gvWLYyomy0D1-uoQHTWPvjXTjr_a


코딩도장도 해보기 Repl.It 도!


#01 Say Hi

def say_hi(name:str, age:int) -> str: // -> 이게 뭘까???????
    return "Hi. My name is {} and I'm {} years old.".format(name, age)
print(say_hi('다희', 22))



#02 Correct Sentence

def c_s(text: str) -> str:
    text = text[0].upper() + text[1:]

    if not text.endswith('.'):
        text += '.'

    return text



#03

def first_word(text: str) -> str:
    text = text.replace('.', ' ').replace(',', ' ').strip() //앞과 뒤의 공백 제거, 한 칸 이상의 연속된 공백 제거
    text = text.split()
    return text[0]

print(first_word("hello, dahee"))



#04