リストのプッシュ&辞書のプッシュ

471 ワード

a = [1,2,3,4,5,6,7,8]
b = [i**3 for i in a]
print(b)


c = [i**2 for i in a if i >=5]

#   ,  set      
a = (1,2,3,4,5)
d = (i **2 for i in a)

ディクショナリガイド
students = {
  '  ':18
  '  ':19
  '  ':20
}
#      
s = [key for key,value in  students.items()]
#   k,v  
s1 = {value:key for key,value in  students.items()}

#       generator ,         
s = (key for key,value in  students.items())