[英]Python, Matrix, replacing bought ticket with "*'
我正在嘗試為一個班級編寫一個程序,給定已售出的票,我的矩陣(15x30)應將已售出的座位“#”替換為已售出的座位“ *”。
seats = []
for i in range (1,16):
for i in range (1,31):
seats.append("#")
while True:
try:
x = int(input("SVP entrer le numéro de la rangée (1-15): "))
for x in range (1,16):
y = int(input("SVP entrer le numéro du siège (1-30): "))
for y in range (1,31):
b = ((x-1) * 30) + (y-1)
s = "*"
for b in len(seats):
seats[b] = seats[s]
z = input("Voulez-vous acheter un autre sièges (o/n)? ")
if z == "o":
return True
else:
return False
except ValueError:
print("Désoler, ce siège à déjà été acheter.")
print(seats)
print("Fin du programme")
File "/Users/staceypoulet/Desktop/temp1.py", line 15, in <module>
if z in len(seats):
for b in len(seats):
TypeError: 'int' object is not iterable
有人可以幫我看看錯誤嗎? 預先感謝任何給我時間的人:)
您要檢查if z in seats
。 len(seats)
是一個整數,沒有成員資格。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.