Q104. 문장을 입력 받아 연순으로 하고 공백(" ") 대신에 하이픈(-)을 출력하는 프로그램을 작성하시오.(while) (400점)
sentence = input("문장을 입력해 주세요: ")
i = _____________ - 1
while i >= 0 :
if sentence[i] == " " :
print("-", end="")
else :
print("%s" % _______________, end="")
i = _____________
- 난이도(1~10) : 4
- 힌트 : 없음
- - 실행 결과
-
문장을 입력해 주세요: 쥐 구멍에 볕들날 있다.
.다있-날들볕-에멍구-쥐
sentence = input("문장을 입력해 주세요: ")
i = len(sentence) - 1
while i >= 0 :
if sentence[i] == " " :
print("-", end="")
else :
print("%s" % sentence[i], end="")
i = i - 1