Avatar ·

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 -:

  1. Why the generation occurs in square brackets, they are usually used when working with indices
  2. What does the first i do for ? Why after range (51) there are no colonies and transfer to a new line with tabulation?
  3. Where else can square brackets use? for write? What are the rules in them?