How does this generator work? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How does this generator work? (/thread-35088.html) |
How does this generator work? - JgKSuperstar - Sep-27-2021 code = "F9E56d" rgb = tuple(int(code[i:i+2], 16) for i in (0, 2, 4))Hi, I don't quite understand the logic of this code. Can you write me this code in a normal for loop so I can understand that? RE: How does this generator work? - Yoriz - Sep-27-2021 code = "F9E56d" rgb = tuple(int(code[i : i + 2], 16) for i in (0, 2, 4)) print(rgb) rgb = [] for i in (0, 2, 4): rgb.append(int(code[i : i + 2], 16)) rgb = tuple(rgb) print(rgb)
RE: How does this generator work? - JgKSuperstar - Sep-27-2021 Thank you so much for your valuable response. |