Pythonda with open fonksiyonuyla dosya oluştururken hata

def not_hesapla(satır):

satır = satır[:-1]

liste = satır.split(",")

isim = liste[0]

not1 = int(liste[1])

not2 = int(liste[2])

not3 = int(liste[3])

son_not = not1 * (3/10) + not2 * (3/10) + not3 * (4/10)

if (son_not >= 90):

    harf = "AA"
elif (son_not >= 85):
    harf = "BA"
elif (son_not >= 80):
    harf = "BB"
elif (son_not >= 75):
    harf = "CB"
elif (son_not >= 70):
    harf = "CC"
elif (son_not >= 65):
    harf = "DC"
elif (son_not >= 60):
    harf = "DD"
elif (son_not >= 55):
    harf = "FD"
else:
    harf = "FF"

return isim + "------------------> " + harf + "\n"

with open(“dosya.txt”,“r”,encoding= “utf-8”) as file:

eklenecekler_listesi = []

for i in file:

    eklenecekler_listesi.append(not_hesapla(i))

with open("notlar.txt","w",encoding="utf-8") as file2:

    for i in eklenecekler_listesi:
        file2.write(i)

def not_hesapla(satır):

satır = satır[:-1]

liste = satır.split(",")

isim = liste[0]

not1 = int(liste[1])

not2 = int(liste[2])

not3 = int(liste[3])

son_not = not1 * (3/10) + not2 * (3/10) + not3 * (4/10)

if (son_not >= 90):

    harf = "AA"
elif (son_not >= 85):
    harf = "BA"
elif (son_not >= 80):
    harf = "BB"
elif (son_not >= 75):
    harf = "CB"
elif (son_not >= 70):
    harf = "CC"
elif (son_not >= 65):
    harf = "DC"
elif (son_not >= 60):
    harf = "DD"
elif (son_not >= 55):
    harf = "FD"
else:
    harf = "FF"

return isim + "------------------> " + harf + "\n"

with open(“dosya.txt”,“r”,encoding= “utf-8”) as file:

eklenecekler_listesi = []

for i in file:

    eklenecekler_listesi.append(not_hesapla(i))

with open(“notlar.txt”,“w”,encoding=“utf-8”) as file2:

    for i in eklenecekler_listesi:
        file2.write(i)

with open(“notlar.txt”,“w”,encoding=“utf-8”) as file2:

kodun bu kısmında anlamsız bir şekilde hata alıyorum bunun sebebi nedir? Bilgilendirirseniz sevinirim.

Kodlara kod görünümü nasıl kazandırılır öğrenmek için aşağıdaki bağlantıyı ziyaret edin.

Aldığınız hata nedir?

Eger tam olarak hangi hata aldiginizi bildirirseniz belki yardimci olabiliriz.
Ama “TypeError: write() argument must be str, not int” hatasini aliyorsaniz (ki anladigim kadariyla notlari eklemeye calisiyorsunuz) write() fonksiyonun sadece str tipini kabul ettigini soyluyor, yani eklediginz veriyi string’e cevirmeniz gerekir:

with open('notlar.txt', 'w') as file2:
       for i in eklenecekler_listesi:
             file2.write(str(i))

Hataniz bu degilse dedigim gibi tam olarak verdigi hata ile paylasiniz lutfen.