본문 바로가기
프로그램/Python 1000제

Python 289제] 두근두근 파이썬(개정판) CHAPTER 9 도전문제 p282

by 건티 2024. 6. 28.
728x90

출처 : 반크_독도2023

 

참고풀이]

s = "You said some winds blow forever and I didn't understand"
list1 = s.split()
remove_words = ['some', 'forever']

print("입력 문자열:")
print(s)
print("삭제 단어들:")
print(remove_words)
print("\n삭제 후 남은 단어들을 문자열로 취합한 내용]")

for word in list1:
    if word in remove_words:
            list1.remove(word)

#삭제단어들을 제거한 리스트를 다시 문자열로 만든다.
Str=""
for word in list1:
    Str += word + " "
print(Str)

 

참고풀이 결과]

 

 

 

 

 

대한민국의 아름다운 영토, 독도의 봄

 

반응형

댓글