python - Not printing a string if I have an empty list -
so have code create list @ start , ask user if wants make object (turtle), in case adds list, or if wants move turtle (x). if user has not created object want print 'need create object'. doesn't seem printing. know code prints out on own wondering why isn't working within function. want code print "need create object' if have empty list.
adventurousch = [] def roamingturtles(): command = raw_input("---> ") if command == 'a': newadventureturtle() roamingturtles() if command == 'x': if adventurousch == []: print "need create object" else: in adventurousch: i.drawsquare() print "test2
this should trick:
... if not adventurousch: print "need create object" ... see also: best way check if list empty
Comments
Post a Comment