클래스 인스턴스 생성

2024. 6. 29. 12:04정보처리,전산/Python

반응형
class jj:
    words =['Propaganda','Regulation','Oligarchy','Corruption','Rhetoric','Authoritarian',
            'Sovereignty','Totalitarianism','Inequality','Nationalism','Activism','Tariff','Economic']

obj=jj()
str=''
for w in obj.words:
    str=str+w[0]

str

 

 

obj = jj()  # jj 클래스의 인스턴스 생성

str = ''  # 빈 문자열 초기화

# obj.words 리스트의 각 단어들의 첫 번째 문자를 str 변수에 추가
for w in obj.words:
    str = str + w[0]

print(str)  # 결과 출력

 
 

 

 

반응형

'정보처리,전산 > Python' 카테고리의 다른 글

네이버 키워드 검색 후 기사 텍스트 추출  (1) 2024.06.30
Python Library  (0) 2024.06.30
map  (0) 2024.06.29
Set  (0) 2024.06.29
LIST  (0) 2024.06.26