states = ["Seoul", "Busan", "Ulsan"]import random#몇개의 아이템이 존재하는지 세어본다.num_states = len(states)#리스트는 0부터 시작하므로, num_states에서 1을 빼준 값을 마지막 범위로 설정한다.random_states = random.randint(0, num_states - 1)
python
You're at a crossroads. Do you want to go left or right? Type "left" or "right"위 문자를 출력하고 싶을 때, 아래와 같은 코드를 입력할 시 오류가 발생한다.print("You're at a crossroads. Do you want to go left or right? Type "left" or "right".\n") 원인 : "string" 안에 " " 와 같은 특수기호가 들어가기 때문이다.해결방법 : string 문을 감싸줄 때 ' ' 로 감싸주어 해결한다.그러나, 이 과정에서 특수기호 '로 인해 오류가 발생하므로 이 또한 해결해주어야 한다.print('You're at a crossroads. Do you want to go left o..