简体   繁体   中英

Python, Matrix, replacing bought ticket with "*'

I am trying to write a program for a class, that given a sold ticket, my matrix (15x30) should replace the available seat "#" by sold seat "*".

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")

However, I have an error:

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

Could anyone help me see the mistake? Thank you in advance to anyone who gives me the time :)

You want to check if z in seats . len(seats) is an integer number and does not have membership.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM