Derivation function, the two codes are the same as the result of drops!

Derivation or connotation (list comprehension) python in the middle: a compact manner processed sequence element lists, dictionaries, and other tuples, and places the result in the form of a sequence of grammar.

1 square_odd=[i**i for i in range(1,11) if i**i %2==0]
2 print(square_odd)
3 
4 
5 for i in range(1,11):
6     square=i**i
7     if square %2==0:
8         print(square)

Guess you like

Origin www.cnblogs.com/bcyczhhb/p/11719399.html