words = ["apple", "banana", "cherry", "date", "fig", "grape"]
transformed_words = list(map(lambda word: word.upper() if len(word)>=5 else word, words))
print(transformed_words)
print()
kor = int(input("국아:"))
eng = int(input("영어: "))
math = int(input("수학: "))
print("----------------")
scores = {'국어':kor, '영어':eng, '수학':math}
avg = sum(scores.values())/len(scores)
for key, value in scores.items():
print(key,":",value)
print("평균: ",avg)
print()
eng_dic = {'one':'하나','two':'둘','three':'셋'}
print("사전 프로그램 시작. 종료는 q입력")
while True:
str = input("입력: ")
if str == 'q':
break
else:
print(eng_dic.get(str,'없음'))
print("사전 프로그램 종료.")
print()
A = {'Kim','Lee','park','Choi'}
B = {'Choi','Jung'}
C = A&B
print("A,B수업을 모두 수강한 사람: ",end="")
for i in C:
print(i,end="")
print()
D = A-B
print("A수업만 수강한 사람: ",end="")
for i in D:
print(i,end=" ")
print()
A = set()
B = set()
for i in range(1,101):
if i%4==0:
A.add(i)
if i%7==0:
B.add(i)
C= A&B
print("4와 7의 공배수: ",sorted(C))
def is_continuous_word(words):
ouput = []
for word in words:
seen = {}
new_word = ""
violation = set()
for i, char in enumerate(word.lower()):
if char in seen:
if seen[char] != i - 1:
violation.add(char)
seen[char] = i
else:
seen[char] = i
if not violation:
ouput.append("continuous word!")
continue
for char in word:
if char.lower() not in violation or new_word.count(char) == 0:
new_word += char
ouput.append(new_word)
return ouput
number_of_words = int(input("number of words? "))
input_words = []
for i in range(number_of_words):
input_words.append(input("word? ").lower())
results = is_continuous_word(input_words)
for result in results:
print(result)