-2
只有當對象的布爾屬性(數組中的對象)設置爲True時,才需要打印一些內容。目前,我想要:帶列表理解的內聯打印
print("Points of Interest: " + (" ".join([str(poi.name) for poi in currentRoom.pointsOfInterest] if [poi.found for poi in currentRoom.pointsOfInterest] else 0)))
我在這裏失去了一些東西,因爲str(poi.name)
被印刷,儘管對象的布爾屬性(poi.found)被設置爲false。
有什麼建議嗎?
在此先感謝
謝謝你,解決它! – Wretch11