2021.06.22
원래 캐글은 주말에 시간을 투자할 생각이였는데,
Courses를 통해 공부를 하는건 평일에도 조금씩 해야겠다는 생각이 들었다.
그래서 오늘은 간단하게 4. Lists 를 공부했다.
풀면서 황당했던 문제
- The next iteration of Mario Kart will feature an extra-infuriating new item, the Purple Shell. When used, it warps the last place racer into first place and the first place racer into last place. Complete the function below to implement the Purple Shell's effect.
def purple_shell(racers): """Given a list of racers, set the first place racer (at the front of the list) to last place and vice versa. """ temp = racers[0] racers[0] = racers[-1] racers[-1] = temp # Check your answer q3.check()
단순히 역순으로 만들라는 문제인줄 알고
racers[::-1]
를 했는데 틀렸다고 해서 뭘 잘못했는지 한참 헤맸다..
알고보니 맨 처음과 마지막을 바꾸는 문제,,,