feat: Initial commit
This commit is contained in:
37
Laboratorio9/esercizio2.py
Normal file
37
Laboratorio9/esercizio2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
posti = [[10 , 20, 30], [10 , 20, 30], [10 , 20, 30]]
|
||||
|
||||
def searchInTable(prezzo):
|
||||
for i in range(len(posti)):
|
||||
for j in range(len(posti[i])):
|
||||
if posti[i][j] == prezzo:
|
||||
posti[i][j] = 0
|
||||
print("Posto prenotato con colonna", i, "riga", j)
|
||||
return
|
||||
|
||||
print("Nessun posto prenotabile con quel prezzo")
|
||||
|
||||
while True:
|
||||
ch = input("Vuoi inserire il posto o il prezzo? (posto/prezzo) ")
|
||||
|
||||
if ch == "posto":
|
||||
x = int(input("Inserisci la colonna: "))
|
||||
y = int(input("Inserisci la riga: "))
|
||||
|
||||
if x > len(posti) or x < 0:
|
||||
print("Colonna non valida")
|
||||
continue
|
||||
|
||||
if y > len(posti[x]) or y < 0:
|
||||
print("Riga non valida")
|
||||
continue
|
||||
|
||||
if posti[x][y] == 0:
|
||||
print("Il posto è già occupato")
|
||||
continue
|
||||
|
||||
posti[x][y] = 0
|
||||
print("Posto prenotato")
|
||||
|
||||
else:
|
||||
prezzo = input("Inserisci il prezzo: ")
|
||||
searchInTable(prezzo)
|
||||
Reference in New Issue
Block a user