モナーのパイソンでゴーゴー

湘南あたりの海辺より

(*´ω`)identityはそれぞれ違う

【実行結果】

f:id:ririruby:20200423203852j:plain

【解説】
scores1と scores2は変数であり内容は同じなのだが割り振られている
identity(アイデンティティ)はそれぞれ違う
 
【コード】
#identityの相違 
scores1 = [80, 40, 50]
scores2 = [80, 40, 50]
print('scores1のidentity:{}'.format(id(scores1)))
print('scores2のidentity:{}'.format(id(scores2)))

#内容が同じかを確認する
if scores1 == scores2:
      print('scores1とscores2は同じ内容です')
else:
      print('scores1と scores2は違う内容です')

#identityが同じかを確認する
if id(scores1) == id(scores2):
      print('scores1とscore2は同じ存在です')
else:
      print('scores1とscores2は違う存在です')
 
print(' ∧ ∧  今日もファイトです!')
print('( ゚Д゚)')
print('海と猫が好き')