Я новичок в Python и пишу один из моих самых больших проектов. Тем не менее, я столкнулся с ошибкой при попытке записи в CSV-файл. Кто-нибудь может увидеть что-то не так с моим кодом? Некоторое время пытался найти ошибку.
a = open("accounts1.csv", "r")
contents1 = a.readlines()
newContents1 = []
for row1 in contents1:
rowStrip = row1.strip("\n")
columns1 = rowStrip.split(",")
newContents1.append(columns1)
b = open("accounts1.csv", "a")
def mainMenu():
menu1 = input("1 - Enter a film you have recently watched: \n"
"2 - Recieve Recomendations o n Films: \n"
"3 - Like a Film: \n"
"4 - Exit")
if menu1 == "1":
films = []
amount = int(input("How many films have you watched recently: "))
for i in range(amount):
film = input("Enter the film name: ")
films.append(film)
films = ", ".join(films)
b.write(films)
menu = input("Enter 1 to login \n"
"Enter 2 to create an account \n"
"Enter 3 to exit")
if menu == "1":
check = True
while check == True:
uname = input("Enter your Username (Case Sensitive)")
pword = input("Enter your Password (Case Sensitive)")
for lines in newContents1:
if lines[1] == uname and lines[0] == pword:
print("You're In")
check = False
mainMenu()
else:
if lines > columns1:
print("Incorrect Password or Username")
again = input("Would you like to try again? (Yes or No)")
if again.lower() == "yes":
check = True
elif again.lower() == "no":
print("Goodbye")
check = False
else:
pass
break
else:
pass
else:
pass