• 18-08-2023, 17:14:29
    #1
    for x, y in sozluk.items():
        for (a, b), (c, d), (e, f), (g, h) in zip(sozluk2.items(), sozluk3.items(), sozluk4.items(), sozluk5.items()):
            toplam = round((b + f), 2)
            toplamEv = round(d + h, 2)
            
            for evG, depG, rakipT in y:
                uza = ortDep[takimlar.index(rakipT)]
                score = evG
                
                for i in apiFixtur:
                    if i["teams"]["home"]["name"] == x and i["teams"]["away"]["name"] == rakipT:
                        is_home_match = True
                        break
                    elif i["teams"]["away"]["name"] == x and i["teams"]["home"]["name"] == rakipT:
                        is_home_match = False
                        break
                
                if is_home_match:
                    uza = ortEvU[takimlar.index(rakipT)]
                
                toplam1 = round(score - uza, 2)
                adjusted_total = round(toplam1 + f, 2)
                
                print(f"{x} Karşısında {rakipT}: Uzaklık: {uza}, Attığı Gol: {score}, Toplam: {adjusted_total}")
    normalde kodun 2 - 4. satırı ayrı bir for döngüsüydü. ikisini birleştirmeye çalışıyorum ama birleştirince her a başına 4 veri vereceğine 16 veri veriyor. bu verilerin ilk 4'ü istediğim gibi diğer 12'si yanlış ve gereksiz.

    5. satırdan başlayarak tüm satırları bir tab eksiltiyorum (içeri alıyorum). o durumda 4 veri veriyor ama bu sefer veriler hatalı oluyor.

    nasıl yapabilirim?
  • 18-08-2023, 17:17:32
    #2
    Merhaba, rica etsem bu kod dizisini dener misiniz.

    for x, y in sozluk.items():
    for (a, b), (c, d), (e, f), (g, h) in zip(sozluk2.items(), sozluk3.items(), sozluk4.items(), sozluk5.items()):
    toplam = round((b + f), 2)
    toplamEv = round(d + h, 2)

    for evG, depG, rakipT in y:
    uza = ortDep[takimlar.index(rakipT)]
    score = evG

    is_home_match = None
    for i in apiFixtur:
    if (i["teams"]["home"]["name"] == x and i["teams"]["away"]["name"] == rakipT) or (i["teams"]["away"]["name"] == x and i["teams"]["home"]["name"] == rakipT):
    is_home_match = i["teams"]["home"]["name"] == x
    break

    if is_home_match is not None:
    uza = ortEvU[takimlar.index(rakipT)] if is_home_match else ortDep[takimlar.index(rakipT)]

    toplam1 = round(score - uza, 2)
    adjusted_total = round(toplam1 + f, 2)

    print(f"{x} Karşısında {rakipT}: Uzaklık: {uza}, Attığı Gol: {score}, Toplam: {adjusted_total}")
  • 18-08-2023, 17:48:01
    #3
    QuantumPix adlı üyeden alıntı: mesajı görüntüle
    Merhaba, rica etsem bu kod dizisini dener misiniz.

    for x, y in sozluk.items():
    for (a, b), (c, d), (e, f), (g, h) in zip(sozluk2.items(), sozluk3.items(), sozluk4.items(), sozluk5.items()):
    toplam = round((b + f), 2)
    toplamEv = round(d + h, 2)

    for evG, depG, rakipT in y:
    uza = ortDep[takimlar.index(rakipT)]
    score = evG

    is_home_match = None
    for i in apiFixtur:
    if (i["teams"]["home"]["name"] == x and i["teams"]["away"]["name"] == rakipT) or (i["teams"]["away"]["name"] == x and i["teams"]["home"]["name"] == rakipT):
    is_home_match = i["teams"]["home"]["name"] == x
    break

    if is_home_match is not None:
    uza = ortEvU[takimlar.index(rakipT)] if is_home_match else ortDep[takimlar.index(rakipT)]

    toplam1 = round(score - uza, 2)
    adjusted_total = round(toplam1 + f, 2)

    print(f"{x} Karşısında {rakipT}: Uzaklık: {uza}, Attığı Gol: {score}, Toplam: {adjusted_total}")
    çıktılarda bir şey değişmedi hocam.

    muhtemelen iç içe for döngüsü kullanıyorum ondan bir sorun çıkıyor döngü sayısı artıyor, bu döngüler birbirlerinden etkilenmeden nasıl hem bağımsız hem de çıktılarını beraber kullanabileceğim bir kod yapısı yazacağım bilmiyorum.