Мне необходимо составить программу по бронированию билетов, я уже составил список мест для сидения, который выглядит примерно так:
def SC1000():
print(" ")
print(" ")
print("PURCHASING MODULE")
print ("Your booking reference number is : ", bookingref)
print("B - to purchase ticket for Business class")
print("E - to purchase ticket for Economy class")
print("M - to return to Main Menu")
bore=input("Enter your choice : ")
if (bore=="B"):
seatingchoice = [[" ", "A", "B", "C", "D", "E"],
["1" , "0" , "0" , "0" , "0" , "0"],
["2" , "0" , "0" , "0" , "0" , "0"]]
print("Seating Arrangement")
print("Business Class")
format_string="{:>4} {:>4} {:>4} {:>4} {:>4} {:>4}"
headers = seatingchoice [0]
header_row = format_string.format(*headers)
print(header_row)
print("-" * len(header_row))
for language in seatingchoice [1:3]:
print(format_string.format(*language))
sc=input("Enter your choice (eg:A3/a3): ")
if sc in open('sc1000.txt').read():
print("This seat has been taken, kindly choose another seat")
SC1000()
else:
customersdata=[]
name =input("Please enter your full name : ")
cfile = open("sc1000.txt","a")
cfile.write("\n")
cfile.write(str(customersdata))
cfile.close()
#for line in cfile:
if (sc=="A1") in open("sc1000.txt","r")():
seatingchoice[2][2]= 1
elif (sc=="A2") in open("sc1000.txt","r")():
seatingchoice[3][2]= 1
elif (sc=="B1") in open("sc1000.txt","r")():
seatingchoice[2][3]= 1
elif (sc=="B2") in open("sc1000.txt","r")():
seatingchoice[3][3]= 1
elif (sc=="C1") in open("sc1000.txt","r")():
seatingchoice[2][4]= 1
customersdata.append(bookingref)
customersdata.append(name)
customersdata.append(sc)
print("Boarding Ticket")
print("____________________________________")
print(" ")
print(" Date:",time.strftime("%d/%m/%Y"))
print(" Time:",time.strftime("%I:%M:%S"))
print(" Name : ",name)
print(" Ferry ID : Ferry 1")
print(" Boarding Time : 9.50am")
print(" Departure : Penang to Langkawi")
print(" Seating Class : Business Class")
print(" Seat Number : ",sc)
print(" Zone : A")
print(" Gate : B1")
print("_____________________________________")
print(" ")
print("Kindly print out the boarding pass as it will be needed at the gate.")
gmm=input("When done printing, press 'D' to go back to the Main Menu. ")
if (gmm=="D"):
mainmenu()
, и это работает, но мне нужнотакже сохраняйте данные, когда пользовательские ключи, в каких местах они хотят, прямо сейчас не сохраняют данные клиентов в текстовый файл, и я уверен, что с моими кодами что-то не так, но я не могу понять, что именно.
ТАКЖЕ , если кто-нибудь захочет поделиться со мной о том, как изменить 0 на 1, когда пользователь выбирает А1, например, это было бы действительно здорово!
Спасибо за вашу помощь