我試圖建立一個數組,但我似乎無法正確理解:我可以獲得我想要的外觀或我想要的功能,但從來沒有。我是計算機科學的新手,現在我已經花了幾個小時的時間,請幫助我向正確的方向發送信息。無法正確顯示數組(Python3)
#tried this and could access elements, but then how do I add the appearance of the list without turning the elements into strings?
board = []
for i in range(10):
board_row = []
for j in range(10):
board_row.append(".")
board.append(board_row)
#This is how I want the board to look, but I can't access elements from this board since it's not a list
for i in range(15):
print(i, " ", end ="")
print("\n")
for j in range(12):
row = ((". " + "") * 10) + ((". " + " ") * 5)
print(row, j)
你想要做什麼? – IanAuld
我需要製作一個陣列看起來像一個板,從那裏它是一個修改後的戰艦遊戲,船隻隨機放置在陣列中 – Sammy
*信息*和*演示*是兩個不同的東西。你需要一個'list'(或類似的東西)來保存*信息*,並且你需要一個把它轉換成正確的* presentation *的函數。 – dlask