[부스트코스] 코칭스터디 9기 : AI Basic 2023 1주차 미션(Q1, Q2) 변형 문제 풀이
2023. 1. 13. 23:59ㆍBOOTCAMP/boostcourse AI BASIC 2023
Q1. num_list 가 홀수인 데이터만 출력하도록 하는 함수를 작성하시오.
Input
#주어진 리스트
num_list = [3, 9, 11, 14, 18, 21, 25, 27]
def get_odd_num(num_list):
for num in num_list[:]:
if (num %2 == 0):
num_list.remove(num)
return num_list
print(get_odd_num(num_list))
Output
[3, 9, 11, 21, 25, 27]
Q2. string 문장을 받아 단어를 역순으로 출력하는 함수를 작성하시오.
Input
sentence = "Life is too short You need python"
def reverse_sentence(sentence):
result = ''
temp = list(sentence.split(' '))
for i in reversed(temp):
result += (i+' ')
return result
print(reverse_sentence(sentence))
Output
python need You short too is Life
'BOOTCAMP > boostcourse AI BASIC 2023' 카테고리의 다른 글
[부스트코스] 코칭스터디 9기 : AI Basic 2023 3주차 미션(Q1, Q2, Q3, Q4) 변형 문제 풀이 (0) | 2023.02.07 |
---|---|
[부스트코스] 코칭스터디 9기 : AI Basic 2023 2주차 미션(Q1, Q2) 변형 문제 풀이 (0) | 2023.02.01 |
[부스트코스] 코칭스터디 9기 : AI Basic 2023 1주차 미션(Q3, Q4, Q5) 변형 문제 풀이 (0) | 2023.01.15 |
Python Object Oriented Programming (2) | 2022.12.26 |
Python Data Structure (2) | 2022.12.25 |