suis assez nouveau à la programmation et ai besoin d'un moyen d'ajouter des données d'entrée d'une fonction et avoir ajouter dans un fichier csvcomment puis-je ajouter à un fichier csv à partir d'une autre fonction en python
def songlists():
with open('songs.csv') as csvfile:
songs = csv.reader(csvfile, delimiter = ',')
x = [row for row in songs]
return x
def menu(x):
print("Songs to Learn 1.0 - ")
songlists()
print(len(x), "songs in list")
print("""Menu :
L - List songs
A - Add new song
C - Complete a song
Q - Quit""")
menuChoice = str(input('>>>'))
while menuChoice != "q":
if menuChoice == "l":
songlists()
i = 0
for row in x:
name, artist, year, learnt = row
print(str(i),'.', learnt, name, artist, "(", year, ")")
i += 1
elif menuChoice == "a":
songlists()
#want to be able to add to the csv file from here and be able to add the new name artists and year etc
#print("??")
elif menuChoice == "c":
print("???")
else:
print("Invalid choice, Choose again")
print("""Menu :
L - List songs
A - Add new song
C - Complete a song
Q - Quit""")
menuChoice = str(input('>>>'))
ce Je voudrais faire est sur l'entrée de "a" par l'utilisateur dans le menu de fonction() il les invite à ajouter le nom et l'artiste etc et ensuite l'ajouter au fichier csv qui est ouvert dans la fonction de liste de chansons. désolé si cette question est mal formatée. merci