How does the code work [I for i in Range (51) if I % 2 == 0]?
📁 список, python, ии
Evens_to_50 = [I for i in range ( 51 ) if i % 2 == 0 ] Print Evens_to_50 This code generates a list of even numbers up to fifty. But I, as new in programming, do not understand some points -:
- Why the generation occurs in square brackets, they are usually used when working with indices
- What does the first i do for ? Why after range (51) there are no colonies and transfer to a new line with tabulation?
- Where else can square brackets use? for write? What are the rules in them?
OL>