그래서 처음에는 목록을 만든 다음 사용자에게 물체 (거북이)를 만들 것인지 물어 보는 코드가 있습니다. 목록, 또는 그가 거북이 (X)를 움직이고 싶다면. 사용자가 개체를 만들지 않은 경우 '개체를 만들 필요가 있습니다.'를 인쇄하고 싶습니다. 그러나 인쇄하는 것 같지 않습니다. 나는 코드가 자체적으로 출력하기 때문에 이것이 왜 함수 내에서 작동하지 않는지 궁금하다. 그래서 기본적으로 난 그냥 코드가 "인쇄 나는 빈리스트가있는 경우 '객체를 생성해야 할빈 목록이있는 경우 문자열을 인쇄하지 않습니다.
adventurousch = []
def RoamingTurtles():
command = raw_input("---> ")
if command == 'A':
newAdventureTurtle()
RoamingTurtles()
if command == 'X':
if adventurousch == []:
print "Need to create object"
else:
for i in adventurousch:
i.drawSquare()
print "test2
상태 : if not adventurousch : ... print "생성 된 객체가 필요함" – levi