SORU
9 Mart 2010, Salı


Python - dizilerini bir liste halinde iki liste öğeleri birleştirme

Aşağıdaki pythonic ulaşmanın yolu nedir?

list_a = [1, 2, 3, 4]
list_b = [5, 6, 7, 8]

#Need to create a of tuples from list_a and list_b

list_c = [(1,5), (2,6), (3,7), (4,8)]

List_c her üyesi list_a gelen olan bir demet, ve ikinci list_b.

CEVAP
9 Mart 2010, Salı


>>> list_a = [1, 2, 3, 4]
>>> list_b = [5, 6, 7, 8]
>>> zip(list_a, list_b)
[(1, 5), (2, 6), (3, 7), (4, 8)]

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BroadCity

    BroadCity

    10 ŞUBAT 2010
  • FlippinWindows | #1 Windows Tutorial Channel!

    FlippinWindo

    23 Mayıs 2010
  • Modus Recordings

    Modus Record

    26 Kasım 2008