게시판
검색 결과: 40
https://dojang.io/mod/forum/discuss.php?d=1766&parent=4011
포럼 상단 오른쪽에 24.5로 검색하면 이전 질문과 답변을 참조할 수 있습니다.
위 링크의 답변을 참조해서 단계별로 실행하면서 디버깅하는 것을 추천합니다.
sentence = input()
X = sentence.split()
answer_1 = X.count('the')
answer_2 = X.count('the,')
answer_3 = X.count('the.')
print(answer_1 + answer_3 + answer_2)
이 코드는 왜 정답이 안되는지 궁금합니다.
x=input()
x = x.strip('.,')
x = x.split()
count = 0
for i in x:
if i == 'the':
count = count + 1
print(count)
이렇게 코드를 작성했는데 5개가 나옵니다. 코드 하나하나 실행 보았을 때 x = x.strip('.,') 코드를 실행해도 ,가 안지워집니다. 어떤 부분이 잘못됬는지 알려주시면 감사하겠습니다.
포럼 상단 오른쪽 검색에 24.5로 검색하면 이미 질문과 답변이 많이 있으니 참고하세요.
https://dojang.io/mod/forum/discuss.php?d=1242&parent=2805
만자리에 콤마를 찍는 기능은 지원하지 않는 것으로 보입니다.
PEP 378 -- Format Specifier for Thousands Separator
https://www.python.org/dev/peps/pep-0378/
파이썬 표준안에 따르면 thousands separator, 천단위 분리자 기능만 있습니다.
[[fill]align][sign][#][0][width][,][.precision][type]이와 같은 형식으로 사용하게 되어 있고, [,]는 , 하나만 쓰면 천단위로 콤마를 찍는 기능만 명시되어 있을 뿐입니다.
[width]는 숫자를 출력할 때의 가로폭을 지정하는 것입니다.
자세한 내용이나 예제는 PEP 378을 참고하세요.
포럼 상단 오른쪽 검색에 24.5로 검색하면 이미 질문과 답변이 많이 있으니 참고하세요.
a= input()
import string
a.strip(string.punctuation)
count1=a.count(' the'or ' the 'or 'the ')
print(count1)
import
string
# Storing the sets of punctuation in variable result
result
=
string.punctuation
# Printing the punctuation values
print
(result)
!"#$%&'()*+, -./:;<=>?@[\]^_`{|}~