Programming

Programming

List comprehension

Cuma ngetest list comprehension buat mencetak tabel perkalian. Awalnya pakai ini saja, [cc lang=”python”]print [x*y for x in range(10) for y in range(10)][/cc] tapi hasilnya malahan jadi perkalian 0 sampai 9 [cc lang=”python”][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 2, 4, […]