파이썬 배열 속 배열
조회수 908회
# -*- coding: utf-8 -*-
#country = [san_fransico,cicago,montrial,new_york,washington,atlelanta,miami,mexico_city,los_angeles,bogota,saint_paaulu,Bueno,rima,santiago]
country=["san","ci","mon","new","at","wa","los","mex","mi","bo","san","bue","ri","sant"]
san=["ci"]
ci=["mon","at","los","mex","san"]
mon=["ci","new"]
new=["wa","mon"]
at=["ci","wa","mi"]
wa=["new","at","mi"]
los=["mex","ci"]
mex=["ci","los","mi"]
mi=["at","wa","mex","bo"]
bo=["san","bue","ri"]
san=["bo","bue"]
bue=["san","bo"]
ri=["bo","sant"]
sant=["ri"]
player_1 = [wa]
player_2 = [wa]
check=raw_input("위치를 설정? (start game?) [y/n]")
if check is "y":
while 1:
place=raw_input("어디로?(Where do you want to move?)")
for s in player_1[0]:
if place in s:
player_1[0]=place
print("player_1의 위치를"+place + "로 이동시켰습니다.(Place player_1 "+place+")")
print("player_1의 현재 위치는"+place+"입니다.(Location of player_1 is "+place+")")
elif place not in s:
print("인접하지 않은 지역입니다.(Can't move)")
break
elif check is "n":
print("끝(end)")
else:
print("명령이 잘못되었습니다.(command_error)")
player_1의 0번 인덱스의 정보를 place의 값으로 바꾸고 싶은데 "new"로 가는 것은 가능한데 "at","mi"로 바뀌지 않네요.
프로그램 실행 예) 현재 wa에 있으면 wa 배열 내에 있는 원소의 이름의 다른 배열로 player_1의 정보를 바꿈.
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력